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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Optimize DAX (Sum / Distinct Count) for a percentage result.

Hi,

 

I am trying to take a certain amount and divide it on some unique products. I've looked in the Performance Analyzer and can see that this DAX query is specially heavy.

 

I have first


Measure A =  CALCULATE(SUM(fact_distribution[frafall]);fact_distribution[Pristypekode] <> "Free")

 

Which is divided on

 

Measure B = COUNTROWS(GROUPBY(fact_distribution;fact_distribution[fk_dim_customer];fact_distribution[fk_dim_publication]))

 

Now from whtat I understand Measure B could be optimized to:

 

COUNTROWS(SUMMARIZECOLUMNS(fact_distribution[fk_dim_publication];fact_distribution[fk_dim_customer]))

 

But...this gives an error that says SummarizeColumns() and AddMissingItems() may not be used in this context.

 

Which from what I understand this is because of the filtering done in the calculate on Measure A?

 

Any other tips on how I can optimize it? I need to take Measure A and divide on Measure B to get a percentage, and then I also need that same percentage in a Last Year version.

 

Thanks for any help.

 

Best,

 

Ali A

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can use the following DAX:

COUNTROWS(SUMMARIZE(fact_distribution;fact_distribution[fk_dim_publication];fact_distribution[fk_dim_customer]))

Would yo like to provide some sample data? We can perform more accurate analysis based on it.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can use the following DAX:

COUNTROWS(SUMMARIZE(fact_distribution;fact_distribution[fk_dim_publication];fact_distribution[fk_dim_customer]))

Would yo like to provide some sample data? We can perform more accurate analysis based on it.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Hi,

 

Out of curiosity - what is the difference? I will look it up online, but if you have a practical way of explaining that would be great.

 

Thanks for the response!


Best,

 

Ali A

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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