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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Power Query if statement with condition dependent on Language format

Hi folks,

 

I'm stumped at this problem and tried to make it simpler by chopping the column [Language] into two columns by delimeter "-" but it doesn't seem to solve my issue.

 

So here's what I'm trying to do. I have two columns 1) SourcePropertyDisplayName and 2) Lanugage

 

Source Property Display Name column has 2 or 3 list of app names that come in the data set as below:

Global IOS App US/UK
Global Android App US/UK

 

Language column has data that come up as : en-en or fr-fr or en-pt or en-us and some more.

 

I'm trying in Power Query to combine an 'if' statement to look at 'SourcePropertyDisplayName' and Language (last 2 letter's) and come up with a 'SourcePropertyDisplayNameMain'

 

So if SourcePropertyDisplayName is Global IOS App US/UK and Lanugage is 'fr-fr' than a new name would come up ina column as 'Global IOS App US/UK French' and if language is anything other than fr-fr than it should be 'Global IOS App US/UK English'.

 

Here's what I wrote but my m language doesn't work.

if [Source Property Display Name] ="Global IOS App US/UK" and left 2[Language] = "fr" then "Global Global IOS App US/UK French" else " Global IOS App US/UK English"

5 REPLIES 5
Nathaniel_C
Super User
Super User

Hi @Anonymous ,
You were almost there.

if [SourcePropertyDisplayName] = "Global IOS App US/UK" and Text.Start([Language], 2) = "fr" then "Global Global IOS App US/UK French" else  "Global IOS App US/UK English"

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel 
global.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thanks so much Nathaniel! If I have let's say 3 sourceNames as I mentioend above, do i keep repeating the if then statement 3 times or nest it somehow? 

 

 

Hi @Anonymous ,

if [SourcePropertyDisplayName] = "Global IOS App US/UK" and Text.Start([Language], 2) = "fr" then "Global Global IOS App US/UK French" else if [SourcePropertyDisplayName] = "x" then "y" else "Global IOS App US/UK English"

lang.PNG

 Yes, so I added another condition if x then y in between.  Look at the picture, shows you three results. If you are getting into this, let me recommend @KenPuls  book, M is for (DATA) Monkey. Easy read and really useful.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




JarroVGIT
Resident Rockstar
Resident Rockstar

Your left function doesn't exist. Replace it with Text.Start function.

https://docs.microsoft.com/en-us/powerquery-m/text-start




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

thanks much @JarroVGIT even though this came up in my search never thought about using it. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.