Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
9 | |
7 | |
6 |