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
ryan_b_fiting
Post Patron
Post Patron

% Change from Earliest Date to Latest Date

Hello Community - 

I am in need of some performance tuning help.  I have measures that are calculating the Avg Price during the earliest selected month, avg price during the latest selected month and the % change between those periods.  The formula is providing the correct values that I need, but the performance on these are very bad.  

Here are my measure:

fx_SalesPrice Avg Earliest Month = 
CALCULATE(
    [fx_Sales Price per 100],
    FILTER(
        'COGS_Master_SalesHist','COGS_Master_SalesHist'[InvoiceMonth] = 
    MINX(
    'COGS_Master_SalesHist',
    'COGS_Master_SalesHist'[InvoiceMonth] )
    )
)

fx_SalesPrice Avg Latest Month = 
CALCULATE(
    [fx_Sales Price per 100],
    FILTER(
        'COGS_Master_SalesHist','COGS_Master_SalesHist'[InvoiceMonth] = 
        MAXX(
    'COGS_Master_SalesHist',
    'COGS_Master_SalesHist'[InvoiceMonth] )
    )
)

fx_SalesPrice pct chg = 
DIVIDE(
    ([fx_SalesPrice Avg Latest Month] - [fx_SalesPrice Avg Earliest Month]), [fx_SalesPrice Avg Earliest Month], 0
)

These measures are producing the correct output, but the table takes 10-12 seconds to refresh anytime I change a slicer on the page. 

 

Are there any suggestions on how to improve the DAX performance on the above measures?

 

Thanks in advance Community!

Ryan 

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure, but please try the below.

 

fx_SalesPrice Avg Earliest Month =
VAR _minmonth =
    MINX ( 'COGS_Master_SalesHist', 'COGS_Master_SalesHist'[InvoiceMonth] )
RETURN
    CALCULATE (
        [fx_Sales Price per 100],
        FILTER (
            'COGS_Master_SalesHist',
            'COGS_Master_SalesHist'[InvoiceMonth] = _minmonth
        )
    )

 

fx_SalesPrice Avg Latest Month =
VAR _maxmonth =
    MAXX ( 'COGS_Master_SalesHist', 'COGS_Master_SalesHist'[InvoiceMonth] )
RETURN
    CALCULATE (
        [fx_Sales Price per 100],
        FILTER (
            'COGS_Master_SalesHist',
            'COGS_Master_SalesHist'[InvoiceMonth] = _maxmonth
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hey @Jihwan_Kim thanks for the response.  I had already tried that, and it gives me near the same performance.

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.