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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Nested if in PowerBI- Power Query

Hi Guys,

Reaching out for help. I'm new in using PowerBI and with PowerQuery.
I'm trying to bring this nested if function that I have used in GSheets:

Here's the table

 

Column UColumn AColumn ABColumn R
Pending Hold179.9128/23/2022
New38.787/02/2022

NoobCodes_0-1661415551543.png

 



The new column should be containing:

Column UColumn AColumn ABColumn RSLA
Pending Hold179.9128/23/2022Out of SLA
New38.787/02/2022Out of SLA


I've tried using try otherwise and calculate function, I'm having a hard time to get it running

Thank you in advance

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

NewStep=Table.AddColumn(PreviousStepName,"SLA",each let a=if [ColumnA]>[Column AB] then "Out of SLA","In SLA",b=Date.From(DateTime.LocalNow()),c=if [ColumnU]<>"Pending Hold" then a else if [ColumnR]=b then "Due Today" else if [ColumnR]<b then "Out of SLA Pending Hold" else "Future Follow Up Date" in try c otherwise "-")

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

I actually figure out already what's wrong with code, I actually state a wrong column name for ColumnAB, @wdx223_Daniel's code did work, thank you so much @jbwtp  as well

Thank you guys 

wdx223_Daniel
Community Champion
Community Champion

NewStep=Table.AddColumn(PreviousStepName,"SLA",each let a=if [ColumnA]>[Column AB] then "Out of SLA","In SLA",b=Date.From(DateTime.LocalNow()),c=if [ColumnU]<>"Pending Hold" then a else if [ColumnR]=b then "Due Today" else if [ColumnR]<b then "Out of SLA Pending Hold" else "Future Follow Up Date" in try c otherwise "-")

Anonymous
Not applicable

Hi @wdx223_Daniel,

Thank you for providing a solution, however, it's giving me a Expression.SyntaxError: Token Eof expected,

can't figure where I went wrong 



Hi @Anonymous,

 

I think this might be missing else instead if comma (,) in this bit:

then "Out of SLA","In SLA".

 

Kind regards,

John

jbwtp
Memorable Member
Memorable Member

a bit more structured, and maybe esier to read:

= Table.AddColumn(PreviousStep,"SLA",each 
        if [Column U]<>"Pending Hold" 
        then
            if [Column A]>[Column AB]
            then "Out of SLA" 
            else "In SLA"
        else
            if Date.From([Column R], "en_US")=Date.From(DateTime.LocalNow())
            then "Due Today"
            else 
                if Date.From([Column R], "en_US")<Date.From(DateTime.LocalNow())
                then "Out of SLA Pending Hold" 
                else "Future Follow Up Date")

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.