Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
aross0602
Frequent Visitor

Slow Measures

I have created 3 simple measures:

Sales = SUM('Transactions'[RevenueExtended])
Transactions = DISTINCTCOUNT(Transactions[OrderId])
Avg Ticket = DIVIDE([Sales], [Transactions])
 
These all load quickly with no issues in my table visual.  From there, I have these measures:
Retail Sales = CALCULATE([Sales], FILTER('Transactions', [SalesChannel] = "IN-STORE")) --loads quickly
Retail Transactions = CALCULATE([Transactions], FILTER('Transactions', [SalesChannel] = "IN-STORE")) --loads slowly
Retail Avg Tkt = CALCULATE([Avg Ticket], FILTER('Transactions', [SalesChannel] = "IN-STORE")) --loads slowly
 
I have a aggregate table that includes the sales and transaction count, as well.  That is not speeding up the latter two measures, and I cannot determine the issue.
 
6 REPLIES 6
v-xiandat-msft
Community Support
Community Support

Hi @aross0602 ,

Everytime the measure is called in an expression, the filter and/or context may be different.  That is why it needs to be evaluated separately each time.

Paste the other measures that are referenced in the final measure, we may be able to optimize those as well.

try this:

Retail Transactions = 
     var Transactions = DISTINCTCOUNT('Transactions'[RevenueExtended])
     return
        calculate(Transactions,Filter('Transactions',[SalesChannel]="IN-STORE"))

Best Regards,

Xianda Tang

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

Hi, 

Did you intend to use RevenueExtended instead of OrderId in the var expression?

Hi @aross0602 ,

My suggestion is just to try not to load measures inside calculate function, since the filter and/or context may be different each time the metric is called in the expression

Best Regards,

Xianda Tang

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

Hi, I tried the formula suggested and it did not work unfortunately (it actually wasn't filtering for some reason).  I did end up figuring it on my own and this is the formula that worked:

 

Retail Transactions = CALCULATE([Transactions], Transactions[SalesChannel] = "IN-STORE")
aj1973
Community Champion
Community Champion

Hi @aross0602 

Did you use Performance analyzer to determine part of the query is taking too long?

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Yes, these are the results:

aross0602_0-1707155208733.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors