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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Juju123
Helper III
Helper III

Countx with summarize very slowly

Hi, 

 I work in DorectQuery Mode. 
i have two tables in my model : 

- Fact table with a lot of row

- Calendar table that is connect to Fact table.


i this following measures in Power BI (they are all measure type columns and not calculated columns) : 

1 - I create a cumulative sum

2 - I create a measure which count number of reference in my model :

DISTINCT REFERENCE = DISTINCTCOUNT(REFERENCE)

3 - i create a third measure which count number of reference with cumul <>0

COUNTX(summarize(FILTER('TABLE_FACT','TABLE_FACT'[RUNNING_TOTAL]<>0),TABLE_FACT[REFERENCE]),[DISTINCT REFERENCE])

 

My problem is with third measure . When I put this measure in the card , it's take a long time to load (5 minutes). 

Have you an idea for speed up this third measure ? 

Thanks you 

 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @Juju123 
Distinct count and summarizing tables can cause slow performance.
Please refer to the linked articles with alternatives:
https://gorilla.bi/dax/optimize-distinctcount/

https://insightsquest.com/2016/11/05/dax-query-tuning-example/

you also can download the Power BI DAX studio to test your tries :

https://daxstudio.org/docs/features/load-powerbi-perf-data/

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

2 REPLIES 2
Ritaf1983
Super User
Super User

Hi @Juju123 
Distinct count and summarizing tables can cause slow performance.
Please refer to the linked articles with alternatives:
https://gorilla.bi/dax/optimize-distinctcount/

https://insightsquest.com/2016/11/05/dax-query-tuning-example/

you also can download the Power BI DAX studio to test your tries :

https://daxstudio.org/docs/features/load-powerbi-perf-data/

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983


Thank you for taking the time to answer my problem and thank you for the 2 links.

 

Sorry, but I've been on Power Bi for 2 months now so I have questions about optimizing my DAX formula : 

COUNTX(summarize(FILTER('TABLE_FACT','TABLE_FACT'[RUNNING_TOTAL]<>0),TABLE_FACT[REFERENCE]),[DISTINCT REFERENCE])

I used the example that was in the article
DEFINED
MEASURE
MEASURE
EVALUATE
ADDCOLUMNS (
ADDCOLUMNS (
SIMMARTZE
CALCULATETABLE
<TABLE>, <FILTER Params>
“Grouping Columns>
),

'Totals of Individual Buckets'
“expression>.
Totals of
expression
)
based on this query I would like to know how I can optimize my query ? 

Thanks in advance

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.