cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

Formulating in power query

Hi!

I'm trying to formulate in power query the following issue:

From a column called "Difference" and the day I am, I want to add a column in which it tells me If I "executed" the activity, "not executed", is "planned" is "extra executed" or simply there's no plan "Unplanned".

So the idea is:

IF [Difference]=0 and not [YTDfinal]=0 then "Executed" If [Difference]<0 and DateTime.Date(Date.Time.LocalNow())>[fechainicio] then "Extra executed" IF [Difference]>0 and DateTime.Date(Date.Time.LocalNow())>[fechainicio] then "Not executed" IF [Difference]>0 and DateTime.Date(Date.Time.LocalNow())<[fechainicio] then "Planned" IF [YTGfinal]>0 then "Planned" else "Unplanned".

 

I made the same formula in power bi desktop and it was ok:

Ejecutadoname = IF(AND(Cruce[Diferencia]=0,Cruce[YTD]<>0),"Executed",IF(AND(Cruce[Diferencia]<0,TODAY()>Cruce[Date]),"Extra executed",IF(AND(Cruce[Diferencia]>0,TODAY()>Cruce[Date]),"Not executed",IF(AND(Cruce[Diferencia]>0,TODAY()<=Cruce[Date]),"Planned",IF(Cruce[YTG]>0,"Planned","Unplanned")))))

 

But now that I want to rewrite the formula in power query it doesn't work

1 ACCEPTED SOLUTION
Super User III
Super User III

Hi @carogomez 

Try this:

= if [Difference]=0 and [YTDfinal]<>0 then "Executed" else if  [Difference]<0 and DateTime.Date(Date.Time.LocalNow())>[fechainicio] then "Extra executed" else if [Difference]>0 and DateTime.Date(Date.Time.LocalNow())>[fechainicio] then "Not executed" else if [Difference]>0 and DateTime.Date(Date.Time.LocalNow())<[fechainicio] then "Planned" else if [YTGfinal]>0 then "Planned" else "Unplanned"

 

Not that M is case sensitive so if  ... then... else has to be lower-case.

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

1 REPLY 1
Super User III
Super User III

Hi @carogomez 

Try this:

= if [Difference]=0 and [YTDfinal]<>0 then "Executed" else if  [Difference]<0 and DateTime.Date(Date.Time.LocalNow())>[fechainicio] then "Extra executed" else if [Difference]>0 and DateTime.Date(Date.Time.LocalNow())>[fechainicio] then "Not executed" else if [Difference]>0 and DateTime.Date(Date.Time.LocalNow())<[fechainicio] then "Planned" else if [YTGfinal]>0 then "Planned" else "Unplanned"

 

Not that M is case sensitive so if  ... then... else has to be lower-case.

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

Helpful resources

Announcements
secondImage

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

secondImage

Power BI Women

Join our monthly meetings and learning sessions.

secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors