Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
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"
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.