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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Martin_Songstad
Frequent Visitor

General advice needed with CALCULATE(COUNTX)) measures

Hi!

 

I have a fairly large fact_table, so I need to consider performance issues, while still allowing users to freely use slicers along several dimensions.

 

My measures look a bit like this - where 'Fact_table' [Event_X] is always 1 or 0.

 

Measure =

CALCULATE (

COUNTX (

Fact_table, [Event_X]

*IF ( complex_boolean_criterium_that_needs_to_be_checked_per_row_1 is true, 1)

*IF ( complex_boolean_criterium_that_needs_to_be_checked_per_row_2 is true, 1)

),

'Fact_table' [Event_X] = 1,

other_easy_critera = ..... ,

other_easy_critera = ..... ,

......,

)

 

Intuitively I would like to send as few rows as possible into the COUNTX-part by filtering on all possible (easy) criteria in the CALCULATE-part, but I am not sure this does the trick - does it? Should I put the easy criteria into the COUNTX-part as well as / instead of the CALCULATE-part to achieve this?

 

Any performance-enhancing advice appreciated 🤔

2 REPLIES 2
amitchandak
Super User
Super User

@Martin_Songstad , My advice would be to convert this <complex_boolean_criterium_that_needs_to_be_checked_per_row_1 > to the column, so that you can use filter and count and avoid the need to countX

Best at Source -> Followed by Power Query and DAX

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks!

 

I managed to reformulate the complex criteria so that they fit in the CALCULATE-part, allowing me to COUNT rather than COUNTX, like this:

 

Measure =

CALCULATE (

COUNT ( Fact_table, [Event_X] ),

'Fact_table' [Event_X] = 1,

other_easy_critera = ..... ,

other_easy_critera = ..... ,

...... ,

complex_criterium_1 = ........(compares_values_across_multiple_tables)............ ,

complex_criterium_2 = ........(compares_values_across_multiple_tables)............

)

 It is still a bit slow. Does the order of the filter criteria matter? I would like to rule out as much as possible of the irrelevant data with the "easy" filter criteria, without also (redundantly) exposing it to those complex ones.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors