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
brentmav
Frequent Visitor

Filter SUMMARIZECOLUMNS based on separate measure

I'm hoping to get some guidance of improving a Report Builder dataset query to reduce the number of rows returned.  At the moment, I'm returning close to 40,000 rows, but ultimately only 18,000 rows would be included in the final report.

 

Dataset is a star schema with 4 dimension tables and 1 fact table.

 

Generically, the query DAX is as follows:

 

EVALUATE
SUMMARIZECOLUMNS (
'DIM_TABLE_1'[CATEGORY_A],
'DIM_TABLE_2'[CATEGORY_B],
'DIM_TABLE_3'[CATEGORY_C],
'DIM_TABLE_4'[CATEGORY_D],
FILTERCONDITION_1,
FILTERCONDITION_2,
FACT_MEASURE_1,
FACT_MEASURE_2
)

 

However, there's a combination of the first 3 categories (from 3 separate dimension tables) that needs to be filtered out based on a separate measure (call it FACT_MEASURE_3 > 0).

 

I imagine I could include that measure in the original DAX query, but I'm not clear how to construct that filter condition and how it fits into the query.  

 

Any help with the structure of the query or related resources would be greatly appreciated.

2 REPLIES 2
Anonymous
Not applicable

Depending on the semantics of your query... you could try the following:

EVALUATE
CALCULATETABLE(
	SUMMARIZECOLUMNS (
		'DIM_TABLE_1'[CATEGORY_A],
		'DIM_TABLE_2'[CATEGORY_B],
		'DIM_TABLE_3'[CATEGORY_C],
		'DIM_TABLE_4'[CATEGORY_D],
		FILTERCONDITION_1,
		FILTERCONDITION_2,
		FACT_MEASURE_1,
		FACT_MEASURE_2
	),
	FILTER(
		SUMMARIZE(
			FactTable,
			'DIM_TABLE_1'[CATEGORY_A],
			'DIM_TABLE_2'[CATEGORY_B],
			'DIM_TABLE_3'[CATEGORY_C]	
		),
		[FACT_MEASURE_3] > 0
	)
)

// 2. version, could be faster

CALCULATETABLE(
	SUMMARIZECOLUMNS (
		'DIM_TABLE_1'[CATEGORY_A],
		'DIM_TABLE_2'[CATEGORY_B],
		'DIM_TABLE_3'[CATEGORY_C],
		'DIM_TABLE_4'[CATEGORY_D],
		FILTERCONDITION_1,
		FILTERCONDITION_2,
		FACT_MEASURE_1,
		FACT_MEASURE_2
	),
	FILTER(
		CROSSJOIN(
			VALUES( 'DIM_TABLE_1'[CATEGORY_A] ),
			values( 'DIM_TABLE_2'[CATEGORY_B] ),
			VALUES( 'DIM_TABLE_3'[CATEGORY_C] )
		),
		[FACT_MEASURE_3] > 0
	)
)

 

Best

D

 

Stachu
Community Champion
Community Champion

you can do something like this:

EVALUATE
FILTER(
SUMMARIZECOLUMNS (
'DIM_TABLE_1'[CATEGORY_A],
'DIM_TABLE_2'[CATEGORY_B],
'DIM_TABLE_3'[CATEGORY_C],
'DIM_TABLE_4'[CATEGORY_D],
FILTERCONDITION_1,
FILTERCONDITION_2,
FACT_MEASURE_1,
FACT_MEASURE_2,
FACT_MEASURE_3,
)
FACT_MEASURE_3>0
)

would that work for you? 

If you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data, I could be more specific. Like this (just copy and paste into the post window).

Column1 Column2
A 1
B 2.5





Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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.

Top Solution Authors