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
daxbeginner
Frequent Visitor

MDX to Dax Code Migration

Hi,

 

I am struggling a bit to rewrite the below MDX code to DAX equivalent:

 

M1:
Iif(Isleaf([Invoice].[Invoice ID]),[Measures].[Product Invoice Amount EUR Days Due Date To Payment Date], SUM(Descendants([Invoice].[Invoice ID],,Leaves), [Measures].[Product Invoice Amount EUR Days Due Date To Payment Date]))

M2:
Iif(Isleaf([Invoice].[Invoice ID]),Int([Measures].[Invoiced Amount EUR]), Int(SUM(Descendants([Invoice].[Invoice ID],,Leaves), [Measures].[Invoiced Amount EUR])))

Result:
Iif([Measures].[M2],[Measures].[M1]/M2,null)

 

Any help is really appreciated.

Thanks in Advance.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @daxbeginner ,

Maybe you can try this:

M1:

=
IF (
    ISFILTERED ( 'Invoice'[Invoice ID] ),
    [Product Invoice Amount EUR Days Due Date To Payment Date],
    SUMX (
        ALLEXCEPT ( 'Invoice', 'Invoice'[Your Level Column] ),
        [Product Invoice Amount EUR Days Due Date To Payment Date]
    )
)

M2:

=
IF (
    ISFILTERED ( 'Invoice'[Invoice ID] ),
    INT ( [Invoiced Amount EUR] ),
    INT (
        SUMX (
            ALLEXCEPT ( 'Invoice', 'Invoice'[Your Level Column] ),
            [Invoiced Amount EUR]
        )
    )
)

Best Regards,
Icey

 

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

2 REPLIES 2
Icey
Community Support
Community Support

Hi @daxbeginner ,

Maybe you can try this:

M1:

=
IF (
    ISFILTERED ( 'Invoice'[Invoice ID] ),
    [Product Invoice Amount EUR Days Due Date To Payment Date],
    SUMX (
        ALLEXCEPT ( 'Invoice', 'Invoice'[Your Level Column] ),
        [Product Invoice Amount EUR Days Due Date To Payment Date]
    )
)

M2:

=
IF (
    ISFILTERED ( 'Invoice'[Invoice ID] ),
    INT ( [Invoiced Amount EUR] ),
    INT (
        SUMX (
            ALLEXCEPT ( 'Invoice', 'Invoice'[Your Level Column] ),
            [Invoiced Amount EUR]
        )
    )
)

Best Regards,
Icey

 

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

Icey
Community Support
Community Support

Hi @daxbeginner ,

I don't know much about the DXA language. Maybe you can refer to this article: Converting MDX to DAX.

 

Best Regards,
Icey

 

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

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.