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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
bikelley
Helper IV
Helper IV

Help with converting DAX to M in most efficient way

Hello, 


I have an M query that needs to changes, but I am not familiar with M. 


The issue is this query relying a lot on [Region]. I want to minimize the use of this column. I want to leverage the [Account.Region_Detail] column and  [Account.Region__c]. If both columns are blank then only use the [Region]. (Those 3 columns coming from 3 different tables)


Condition - If we used [Region] we have to change the value "META" = "iMETA" and "EMEA" = "EUR". 


For the DAX query I came up with,  please help me to add the condition as well. (my dax query is missing the condition, not sure how to add it in the best way) 

 

Region_New = IF(df_ProjectSummary[Account.Sub_Region__c] = "iMETA", "iMETA",
                IF(df_ProjectSummary[Account.Region__c] = "EMEA", "EUR",
                    IF(df_ProjectSummary[Account.Region__c] = "" && df_ProjectSummary[Account.Sub_Region__c] ="", df_ProjectSummary[Region],
                        df_ProjectSummary[Account.Region__c])))

 


Any help to convert this to M will really help full, and also please help me to add the condition as well in a most efficient way. 

Data looks like- 

 

Note - I tried editing this but I got few errors, this is the only one I captured, "Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?".


Thank you 

1 ACCEPTED SOLUTION

@bikelley Maybe:

= Table.AddColumn(#"Replaced Value1", "Region Adj",
each if [Account.Sub_Region__c] = "iMETA" then "iMETA"
else if [Account.Region__c] = "EMEA" then "EUR"
else if Text.Contains([Region],"META") or Text.Contains([Region],"EMEA") then "EUR"
else if [Account.Region__c] = "" and [Account.Sub_Region__c] ="" then [Region]
else [Account.Region__c])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

@bikelley Seems like maybe:

= Table.AddColumn(#"Replaced Value1", "Region Adj",
each if [Account.Sub_Region__c] = "iMETA" then "iMETA"
else if [Account.Region__c] = "EMEA" then "EUR"
else if [Account.Region__c] = "" && [Account.Sub_Region__c] ="" then [Region]
else [Account.Region__c])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Thank you so much for taking the time to look at my issue. I think your Power Query is good if I can add the condition. The issue that I am stuck in I also have to include the below condition when we using [Region] in the above Power Query. Because [Region] column has "META" and "EMEA", I need to change the name as below. 

 

Can you please help me to add the below condition to Power Query (the best and efficient way)? 

Contains([Region],"META") then "EUR"
Contains([Region],"EMEA") then "EUR"

 Again, thank you so much for your help and time. 

@bikelley Maybe:

= Table.AddColumn(#"Replaced Value1", "Region Adj",
each if [Account.Sub_Region__c] = "iMETA" then "iMETA"
else if [Account.Region__c] = "EMEA" then "EUR"
else if Text.Contains([Region],"META") or Text.Contains([Region],"EMEA") then "EUR"
else if [Account.Region__c] = "" and [Account.Sub_Region__c] ="" then [Region]
else [Account.Region__c])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank you so much. This works for me. I really appreciate your help. 

@Greg_Deckler  Thank you so much, I think this should work, I will get back to you asap. After I check on this. Again, I truly appreciate your help. 

m3tr01d
Continued Contributor
Continued Contributor

Hi,
for this kind of thing, it is better to do it in Power Query, why do you need to do it in DAX?

What's the problem with your Power Query approach?

I am not familiar with Power Query. I was running into so many errors. That is the issue.  Thank you so much 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.