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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.