Calculate - Apply Filter to Calendar Table

DaveBlakeMAAT

Board Regular
Joined
Feb 28, 2016
Messages
190
Hi

I am having an issue with the following DAX which I just can't seem to get working properly

Code:
Net Expenditure:=VAR CutOff =
    MAX ( 'Calendar'[FiscalYear] ) - 2
RETURN
    CALCULATE (
        SUM ( SupplierNetExpenditure[NET_AMOUNT] ),
        FILTER ( 'Calendar', 'Calendar'[FiscalYear] > CutOff )
    )

It is not filtering the data for FiscalYear, it is returning all results, If I replace the CutOff variable to 2018, I get the expected results. If I create a measure using the variable definition (MAX ( 'Calendar'[FiscalYear] ) - 2) it returns 2018, which is what I expect.

My instinct is telling me i am having a battle with filter context, but i am not sure what else to try!

Any advice will be greatly received.

Regards

Dave
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
what you are trying to do is modify the filter context. As a general rule, you should remove filters first, then reapply the filters you need.
try this

Code:
Net Expenditure:=VAR CutOff =
MAX ( 'Calendar'[FiscalYear] ) - 2
RETURN
CALCULATE (
SUM ( SupplierNetExpenditure[NET_AMOUNT] ),
FILTER (ALL( 'Calendar'), 'Calendar'[FiscalYear] > CutOff )
)
 
Upvote 0
Hi Matt

Thanks for your speedy response, unfortunately I tried that previously and it returns the grand total for each year to my pivot (Sort of!)
1597390805806.png


My objective is to only return monthly results for this fiscal year and the previous year (for comparatives, I am not interested in anything older for this specific Pivot, however I need to keep the source data for other aspects and therefore can not filter out at source).
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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