ooptennoort
Board Regular
- Joined
- Mar 29, 2021
- Messages
- 67
- Office Version
- 365
- Platform
- Windows
Dear experts,
I am trying to convert an excel formula into M for PQ but I think it cannot be done. I need to generate an interval (of 2's) from 2 values.
The 3rd column would be great. (Did not even attempt the 4th column.)
This was my excel formula:
=IF([@Second]=0,MROUND([@First],2)&"-"&(MROUND([@First],2)+2),MROUND(MAX(0,AVERAGE([@First],[@Second])-1),2)&"-"&MROUND((AVERAGE([@First],[@Second])+1),2))
This is what I produced so far (when I ran into errors, esp. because of &):
= Table.AddColumn(Add2Interval, "2Interval", each if [Second]=0 then Number.ToText(RoundingMode.ToEven([First]/2)*2)
else if [Second]=[First] then [First]
else Number.ToText(RoundingMode.ToEven([Second]/2)*2-1)&"-"&Number.ToText(RoundingMode.ToEven([Second]/2)*2+1), type text)
Anyone?
I am trying to convert an excel formula into M for PQ but I think it cannot be done. I need to generate an interval (of 2's) from 2 values.
First | Second | Great result | Ideal Result |
2.5 | 12.5 | 6-8 | 2-4;4-6;6-8;8-10;10-12;12-14 |
4.2 | 13.2 | 8-10 | 4-6;6-8;8-10;10-12;12-14 |
8 | 1 | 4-6 | 0-2;2-4;4-6;6-8 |
0.1 | 4.9 | 2-4 | 0-2;2-4;4-6 |
116 | 117 | 116-118 | 116-118 |
34 | 34 | 34-36 | 34-36 |
32.3 | 32.3 | 32-34 | 32-34 |
5 | 13 | 8-10 | 4-6;6-8;8-10;10-12;12-14 |
The 3rd column would be great. (Did not even attempt the 4th column.)
This was my excel formula:
=IF([@Second]=0,MROUND([@First],2)&"-"&(MROUND([@First],2)+2),MROUND(MAX(0,AVERAGE([@First],[@Second])-1),2)&"-"&MROUND((AVERAGE([@First],[@Second])+1),2))
This is what I produced so far (when I ran into errors, esp. because of &):
= Table.AddColumn(Add2Interval, "2Interval", each if [Second]=0 then Number.ToText(RoundingMode.ToEven([First]/2)*2)
else if [Second]=[First] then [First]
else Number.ToText(RoundingMode.ToEven([Second]/2)*2-1)&"-"&Number.ToText(RoundingMode.ToEven([Second]/2)*2+1), type text)
Anyone?