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

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

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

Thanks a lot all!

problem solved,

John 

sevenhills
Super User
Super User

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

 

HotChilli
Super User
Super User

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?

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.