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

Optimizing the Growth calculation DAX

Hi Team,

 

Please could anyone help me in simplying this DAX. This query is consuming a lot of memory in SAP HANA DB and the visuals are not getting loaded.

 

 YOY Growth % =
VAR b =
    MAX ( 'Table'[Fiscal Qtr Ref] )
VAR Nr =
    SUMX (
        FILTER ( 'Table', 'Table'[Field1] = "ABC" || 'Table'[Field1] = "XYZ" ),
        'Table'[Current Year Sales]
    )
VAR DR =
    IF (
        b <> 0,
        CALCULATE (
            SUM ( 'Table'[Current Year Sales] ),
            FILTER (
                ALL ( 'Table'[Fiscal Qtr Ref], 'Table'[Fiscal Qtr Year] ),
                'Table'[Fiscal Qtr Ref] = b - 4
            )
        ),
        CALCULATE (
            SUM ( 'Table'[Prior Year Sales] ),
            FILTER (
                ALL ( 'Table'[Fiscal Qtr Ref], 'Table'[Fiscal Qtr Year] ),
                'Table'[Fiscal Qtr Ref] = b - 4
            )
        )
    )
RETURN
    DIVIDE ( ( Nr - DR ), DR, 0 )
1 ACCEPTED SOLUTION
Vinod_V_12
Frequent Visitor

I have created two Variables for the script in VAR DR and used the IF condition after the RETURN clause to pull it.

 

This worked.

View solution in original post

3 REPLIES 3
Vinod_V_12
Frequent Visitor

I have created two Variables for the script in VAR DR and used the IF condition after the RETURN clause to pull it.

 

This worked.

NidhiBhusari
Helper IV
Helper IV

Hey @Vinod_V_12 can you explain the scenario along with it please share sample data.

Sure..

 

The visual is Matrix. Rows has 8 hierachy dimensions + Column has Fiscal Qtr Year + Values has Sales and Growth % as the fields. The data needs to be shown for 3 Fiscal year both by Quater and Month.

 

When the Growth% field is added in to the visual it breaks.

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.