cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
Super User I
Super User I

Re: Power Query if statement with condition dependent on Language format

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!




Highlighted
Super User IV
Super User IV

Re: Power Query if statement with condition dependent on Language format

Hi @yyztosfo ,
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!




Highlighted
Frequent Visitor

Re: Power Query if statement with condition dependent on Language format

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? 

 

 

Highlighted
Frequent Visitor

Re: Power Query if statement with condition dependent on Language format

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

Highlighted
Super User IV
Super User IV

Re: Power Query if statement with condition dependent on Language format

Hi @yyztosfo ,

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!




Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors