The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I wish to add column in the query based on flag in the incoming data.
To achieve is:
based on flag value :
if flag < 1, then Red
else if flag is >0 and flag < 3 then yellow
else green
I tried to do it with DAX function as below : ([D] is my flag columns
IF (AND([D] >0,[D]<3),"Yellow",IF([D] < 1,"Red","Green"))
Error:
Tried Switch function too:
= SWITCH(TRUE(),
[D] <= 0, "Red",
AND([D] >0, [D] < 3), "Yellow",
"Green")
Error:
Solved! Go to Solution.
@Anonymous In Power Query, make sure you are following case-sensitive rules. As M-code is case-sensitive and IF is not same as if.
Please change the logic in Power Query as below
= Table.AddColumn(#"Added Index1", "Custom", each if [Flag]<1 then "Red" else if [Flag]>0 and [Flag]<3 then "Yellow" else "Green")
In DAX, it will be
IF(Test154[Flag]<1,"Red",IF(AND(Test154[Flag]>0,Test154[Flag]<3),"Yellow","Green"))
Proud to be a PBI Community Champion
@Anonymous In Power Query, make sure you are following case-sensitive rules. As M-code is case-sensitive and IF is not same as if.
Please change the logic in Power Query as below
= Table.AddColumn(#"Added Index1", "Custom", each if [Flag]<1 then "Red" else if [Flag]>0 and [Flag]<3 then "Yellow" else "Green")
In DAX, it will be
IF(Test154[Flag]<1,"Red",IF(AND(Test154[Flag]>0,Test154[Flag]<3),"Yellow","Green"))
Proud to be a PBI Community Champion
Ola..!! It workd for me. Thanks
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
82 | |
77 | |
46 | |
39 |
User | Count |
---|---|
135 | |
109 | |
70 | |
64 | |
55 |