Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi All,
Need your Help....for DAX Statement
Trying to list some countries I want and show one thing if true, and another thing if false.
Below gives an syntax error
= Table.AddColumn(Custom1, "DayLink", each If [Year] IN ({“January", "February", "March", "April", "June", "July", "August", "September"}) then [Year] & [Day] else [Year])
hard way.....i got
= Table.AddColumn(#"Changed Type", "DayLink", each if [Year] = "January" then [Year] & [Day]
else if [Year] = "February" then [Year] & [Day]
else if [Year] = "March" then [Year] & [Day]
else if [Year] = "April" then [Year] & [Day]
else if [Year] = "May" then [Year] & [Day]
else if [Year] = "June" then [Year] & [Day]
else if [Year] = "July" then [Year] & [Day]
else if [Year] = "August" then [Year] & [Day]
else if [Year] = "September" then [Year] & [Day]
else [Year]
DAX syntax for IN a list of values
Thanks & Regards,
Sam
Solved! Go to Solution.
Hi Dong,
Thanks for the reply...
Am getting data type error message when using List.Contains
= Table.AddColumn(#"Changed Type1", "Custom", each if List.Contains({“January", "February", "March", "April", "June", "July", "August", "September"},[Year]) then [Year] & [Day] else [Year])
"Expression.Error: 10 arguments were passed to function which expects between 2 and 3. Details: Pattern= Arguments=List
Regards,
Sam
Hi @Anonymous ,
How about the result after you follow the suggestions mentioned in my original post?
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Your formula is Power Query M formula and "IN" function is DAX function. We can change your formula to following to meet your requirement.
= Table.AddColumn(#"Changed Type1", "Custom", each if Text.Contains("January February March April June July August September",[Year]) then [Year] & [Day] else [Year])https://docs.microsoft.com/zh-cn/powerquery-m/text-contains
Or
= Table.AddColumn(#"Changed Type1", "Custom", each if List.Contains({“January", "February", "March", "April", "June", "July", "August", "September"},[Year]) then [Year] & [Day] else [Year])https://docs.microsoft.com/zh-cn/powerquery-m/list-contains
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Dong,
Thanks for the reply...
Am getting data type error message when using List.Contains
= Table.AddColumn(#"Changed Type1", "Custom", each if List.Contains({“January", "February", "March", "April", "June", "July", "August", "September"},[Year]) then [Year] & [Day] else [Year])
"Expression.Error: 10 arguments were passed to function which expects between 2 and 3. Details: Pattern= Arguments=List
Regards,
Sam
Hi @Anonymous ,
Sorry for my mistake, use the following formula:
= Table.AddColumn(#"Changed Type1", "Custom", each if List.Contains({{“January"}, {"February"},{ "March"}, {"April"},{ "June"},{ "July"}, {"August"},{ "September"}},[Year]) then [Year] & [Day] else [Year])
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |