DAX formulas working, but wont give correct result when slicer changes made.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
765
Hello friends, hope all is well! please help.

The following DAX formulas works fine, and displays the average, max and min of values of all branches.
= CALCULATE(average(DB[LTM]), FILTER( DB, DB[Year]=earlier(DB[Year])&&DB[Month]=earlier(DB[Month])&&DB[Item]=earlier(DB[Item])) )
= CALCULATE(MAX(DB[LTM]), FILTER( DB, DB[Year]=earlier(DB[Year])&&DB[Month]=earlier(DB[Month])&&DB[Item]=earlier(DB[Item])) )
= CALCULATE(MIN(DB[LTM]), FILTER( DB, DB[Year]=earlier(DB[Year])&&DB[Month]=earlier(DB[Month])&&DB[Item]=earlier(DB[Item])) )

problem is I don't get the correct average, min, or max if I choose less branches through the slicers. (i.e. all branches have to be selected).

I wish for the formula to adjust based on the slicer selections. can that be done?

thank you so much in advance!
1.PNG
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Possibly your slicer is looking at old cached data. In all my powerqueries and powerpivot sheets I got a macro to 'refresh' the caches linked to a buttonshape with the respective macro assigned. It's with complex setups rather slow hence why MS is likely to have chosen to go the cache route. A Snip from my code

VBA Code:
140             With pt.PivotCache '26.05.2019 with merges
150                 .MissingItemsLimit = xlMissingItemsNone: .MissingItemsLimit = xlMissingItemsDefault: .Refresh
190             End With 'pt.
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top