Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Dear all,
I have written a "If" function in microsoft Power Query M.
It is not a difficult one and works, however one line that does not differ from others gives a wrong result. And i dont get it why.
here the function:
if [#"Zug-Km"] = [#"K-Zug"] and [#"K-Zug Km"] = [#"K-Zug"] and [#"V-Zug"] = 0 and [#"L-Zug"] = 0 then
"verstärkt z. K_Zug"
else if [#"Zug-Km"] = [#"V-Zug"] and [#"K-Zug Km"] = [#"V-Zug"]*2 and [#"K-Zug"] = 0 and [#"L-Zug"] = 0 then
"verstärkt z. V_Zug"
else if [#"Zug-Km"] = [#"L-Zug"] and [#"K-Zug Km"] = [#"L-Zug"]*3 and [#"K-Zug"] = 0 and [#"V-Zug"] = 0 then
"verstärkt z. L_Zug"
else
"fehler"
this is the part that supposed to be right, but makes problems:
if [#"Zug-Km"] = [#"V-Zug"] and [#"K-Zug Km"] = [#"V-Zug"]*2 and [#"K-Zug"] = 0 and [#"L-Zug"] = 0 then
"verstärkt z. V_Zug"
Could it be rounding errors? I see only 2 digits in you screenshot, but may be there are more?
Like 0.9999 * 2 <> 4
Only showing 2 decimals it would show 1.00 * 2.00 but testing for eauality will still return false.
which rows of table you prefered to filter, can you explain the conditins?
Hello Ahmedx, Thx for your quick response and idea. unfortunately is this not the hoped solution. But my fault, the picture shows only positive figures. there also negativ figures. the logic of this table is not that easy to explain. actually i was just wondering because my syntax and logic of my function is totally right.
the one line only, even it is same as the two above, shows a different result.
I guess i have to find another way.
Thanks anyway for your good try.
best regards nakiko
and also check what the amount will be if you write it like this
=[#"Zug-Km"] + [#"V-Zug"] + [#"K-Zug"] + [#"L-Zug"]
rewrite this
if [#"Zug-Km"] = [#"V-Zug"] and [#"K-Zug Km"] = [#"V-Zug"]*2 and [#"K-Zug"] = 0 and [#"L-Zug"] = 0 then
"verstärkt z. V_Zug"
like this
IF ([#"Zug-Km"] + [#"V-Zug"] + [#"K-Zug"] + [#"L-Zug"]) =[#"K-Zug Km"] then "verstärkt z. V_Zug"