Forum Discussion
DAX IF to M IF
Hi,
Pretty new to PBI and could use some help to convert my DAX IF statement to M.
Why M? because I want this IF statement to by performed each time I load in the data.
I was able to write the desired IF statement in DAX but not familiar with M syntax....
Here is the DAX IF statement I would like to preform in the Query editor:
Especially the bold marked statement I find difficult to transform to M.
Soort = IF([Account] = 1170811 || [Account] = 1170812 , "VAT",
IF([Account] = 1170820, "RC",
IF([DocumentNo]=7400172849 && [Amount in doc. curr.]=-10022208.20 && [Assignment]="CO2", "RC",
IF([DocumentNo]=7435013206 && [Amount in doc. curr.]=-1236447 && [Assignment]="CO2", "RC",
IF([DocumentNo]=7435013376 && [Amount in doc. curr.]=-10397538.91&&[Assignment]="CO2","RC",
IF(AND([Account]=1170810, [Assignment]="INTEREST" || [Assignment]="INTEREST RC"|| [Assignment]="INTEREST 2020"|| [Assignment]="INTEREST RC USD"), "RC",
IF(AND([Account]=1170810, [Assignment]="SWEEP"), "RC",
IF(AND([Account]=1170810, [Assignment]="FUNDING OCI"), "RC",
IF(AND([Account]=1170810, [Assignment]="LOAN"),"RC",
IF(AND([Account]=1170810, [Assignment]="CO2"), "CO2",
IF(AND([Account]=1170810, [Assignment]="GAS HEDGE"),"GAS",
IF([Account]=1170810 && [Assignment]= "CO2 RC" && [Amount in doc. curr.]=22634006.04,"RC"
))))))))))))
Who can explain the basics of the M language syntax relating to IF statements??
Solution is also more than welcome because I can see how DAX to M works. 🙂
Thanks,
Erwin
Hey Anonymous ,
the syntax is like this:
if [column] <> null or [column] = "myValue" then "Result" else "Other result"For your case this should do it:
if [Account]=1170810 and ([Assignment]="INTEREST" or [Assignment]="INTEREST RC" or [Assignment]="INTEREST 2020" or [Assignment]="INTEREST RC USD") then "RC" else nullIf you give some sample data I can also send you a proposal.
If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
3 Replies
- selimovd
Most Valuable Professional
Hey Anonymous ,
the syntax is like this:
if [column] <> null or [column] = "myValue" then "Result" else "Other result"For your case this should do it:
if [Account]=1170810 and ([Assignment]="INTEREST" or [Assignment]="INTEREST RC" or [Assignment]="INTEREST 2020" or [Assignment]="INTEREST RC USD") then "RC" else nullIf you give some sample data I can also send you a proposal.
If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic