cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jwi1
Post Patron
Post Patron

converting DAX formula to power query M formula

Hi all,

Hope someone can help me to convert below DAX formula to power Query M formula

Thanks, John

 

time_ordered = 
IF (
    'daily_event_reefer_report (2)'[event_type_gkey] = 241,
    IF (
        'daily_event_reefer_report (2)'[event_type_gkey_previous] = 243,
        'daily_event_reefer_report (2)'[placed_time_previous],
        0
    ),
    IF (
        'daily_event_reefer_report (2)'[event_type_gkey] = 240,
        IF (
            'daily_event_reefer_report (2)'[event_type_gkey_previous] = 242,
            'daily_event_reefer_report (2)'[placed_time_previous],
            0
        ),
        0
    )
)

 

3 ACCEPTED SOLUTIONS
HotChilli
Super User II
Super User II

You'll want to add a custom column and write a reasonably complex if.. then.. else  statement to cope with the different cases.  Looks like it's just a matter of working through it.  Is that enough to help you progress?

View solution in original post

sevenhills
Impactful Individual
Impactful Individual

I agree with @HotChilli  

 

Add custom column and in the custom column formula use; make sure if then else is in lower case (it will show blue color). nested lines is more of readability

 

if ... 

then

   if

   then

   else

else

   if

   then

         if

         then

         else

   else

 

Sample (not your requirement)

 

sevenhills_0-1627416508317.png

 

View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @jwi1 ,

Choose Add Column – Custom Column, the custom column formula is:

if [event_type_gkey]=241
then
if [event_type_gkey_previous] = 243
then [placed_time_previous]
else "0"
else
if [event_type_gkey] =240
then
if [event_type_gkey_previous] =242
then [event_type_gkey_previous]
else "0"
else "0"

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @jwi1 ,

Choose Add Column – Custom Column, the custom column formula is:

if [event_type_gkey]=241
then
if [event_type_gkey_previous] = 243
then [placed_time_previous]
else "0"
else
if [event_type_gkey] =240
then
if [event_type_gkey_previous] =242
then [event_type_gkey_previous]
else "0"
else "0"

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

Thanks a lot all!

problem solved,

John 

sevenhills
Impactful Individual
Impactful Individual

I agree with @HotChilli  

 

Add custom column and in the custom column formula use; make sure if then else is in lower case (it will show blue color). nested lines is more of readability

 

if ... 

then

   if

   then

   else

else

   if

   then

         if

         then

         else

   else

 

Sample (not your requirement)

 

sevenhills_0-1627416508317.png

 

View solution in original post

HotChilli
Super User II
Super User II

You'll want to add a custom column and write a reasonably complex if.. then.. else  statement to cope with the different cases.  Looks like it's just a matter of working through it.  Is that enough to help you progress?

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors