Forum Discussion
Macro or Variable For Reuseing Filters in CALCULATE
I have to create several CALCULATE() statements both off actual expense and different budget types etc. I have several sets of filters that I need to apply in CALCULATE. I was wondering if there was a creative way to write the filters "once" and reuse them almost like a variable? That way if they do change I only change one spot, I don't risk typos and it is just cleaner.
so calcualte mgiht look like Calculate (<expression> , EXPENSE_TYPE)
and EXPENSE_TYPE would be replaced with something like
KEEPFILTERS (
VALUE ( 'Head Account Relations'[Head Account] ) >= 50000
&& VALUE ( 'Head Account Relations'[Head Account] ) <= 79999
&& VALUE ( 'Head Account Relations'[Head Account] ) <> 56950
),
KEEPFILTERS (
VALUE ( 'Financial Actuals Table'[Account] ) <> 96910
&& VALUE ( 'Financial Actuals Table'[Account] ) <> 96950
) ,
KEEPFILTERS( VALUE('Main Project Master File - PMF'[PMF Project Type] ) >= 30 &&
VALUE( 'Main Project Master File - PMF'[PMF Project Type] ) <= 69
)
Any ideas or thoughts?
I would think this is something others wold want.
thanks
Alan
4 Replies
- DataInsights
Super User
See the link below on calculation groups.
https://www.sqlbi.com/blog/marco/2020/07/15/creating-calculation-groups-in-power-bi-desktop/
- asjones
Helper V
I think calculation groups are opposite of what I am after.
I posted the question on the Guy in a Cube Live Discussion. They gave a different possible solution that i am confused on, but said otherwise it does not exist. See the video linked ot the time of the question
https://youtu.be/hLQ5St1g4S4?t=1047 - PaulDBrown
Community Champion
Very rudimentary, but I use a word doc/notepad for this and copy/paste. But it would be great if there was the option within PBI for sure.
(another option is to have a report page with text boxes to copy and paste from)
- v-deddai1-msft
Community Support
Hi asjones ,
As far as I know, It can't be achieved in Power BI. Calculation group is the best way to fit your ideas.
Best Regards,
Dedmon Dai