Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nakiko76
Regular Visitor

Power Query M function : If function makes problems

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"

 

 

Nakiko76_0-1727256440329.png

 

5 REPLIES 5
PwerQueryKees
Super User
Super User

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.

Omid_Motamedise
Super User
Super User

which rows of table you prefered to filter, can you explain the conditins?


If my answer helped solve your issue, please consider marking it as the accepted solution.
Nakiko76
Regular Visitor

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 

Ahmedx
Super User
Super User

and also check what the amount will be if you write it like this

=[#"Zug-Km"] + [#"V-Zug"] + [#"K-Zug"] + [#"L-Zug"]
Ahmedx
Super User
Super User

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"

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.