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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rgopalr
Frequent Visitor

Calculations and Filters on Aggregated Measures

I have a Sales table, Budget table and a dimension table for Store and Date. 

Sales table:

DateStoreSales
1/1/2020Store 120
1/1/2020Store 250
1/1/2020Store 3100
1/1/2020Store 180
1/1/2020Store 320

Budget Table:

DateStoreBudget
1/1/2020Store 150
1/1/2020Store 2100
1/1/2020Store 3100

 

The sales table and budget table are connected through DimDate and DimStore using Many to 1 relationship. I have a calculated measure that calculates the variance to budget using the formula VTB = (Sales - Budget)/Budget.

 

The question is i wanted to get the number of stores that exceeds the budget and have this slicable by Date. For ex. in the insatnce of the above table, Store 1 and Store 3 exceeds the budget for the month so the measure (which i am using to display in a card) should show 2.

 

When i use the filter on aggregated columns it is filtering the underlying tables and not giving me the right values for the measure. Any help is greatly appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[# Stores VTB+] =
	countrows(
		filter(
			DimStore,
			[VTB] > 0
		)
	)

Best

D

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

[# Stores VTB+] =
	countrows(
		filter(
			DimStore,
			[VTB] > 0
		)
	)

Best

D

Thanks so much darlove! That worked like a charm!!

mahoneypat
Microsoft Employee
Microsoft Employee

I am not clear on your model/relationships.  In your last post you said Sales and Budget tables have relationship on Store and Date?  In any case, assuming your relationships and your VTB measure are working correctly, you could try this approach

 

Make another measures called Pct Budget that is similar to your VTB but the Return is Sales/Budget instead, then use this measure:

 

Num Stores Over Budget = var summarytable= addcolumns(summarize(Sales, Sales[Store]), "Budget", [Pct Budget])

return countrows(Filter(summarytable, [Budget]>1))

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Greg_Deckler
Community Champion
Community Champion

Use ALL or ALLEXCEPT in your measure to override your filters. Could also possibly use REMOVEFILTERS.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg_Deckler. I dont want to override the filters. I want the measure (Number of stores exceeding budget) to be slicable by date filters. I have to to some kind of summarize to get to it. But could not figure it out.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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