Return Filter Names of current Filter Context

ImkeF

Well-known Member
Joined
Feb 1, 2015
Messages
544
Is there a way to return the filter name(s) of the current filter context in a DAX-measure?

Background: Want to calculate aggregates on time series only if they are complete. I.e. if it is a monthly time series with values from Jan 2014-Aug 2015, then the aggregations for 2014 will all be shown: annual, as well as all 4 quarters. But for 2015 only the first 2 quarters aggregations shall be shown (no unfinished quarters and year).

So I need to check which filter context applies in the current cell (annual or quarter) in order to determine the necessary conditions (for an annual aggregations of monthly time series there must be 12 values reported already, whereas for a quarterly aggregation I need only 3 monthly values (..and for a quarterly time series only 4 reported values are necessary for the annual aggregation).

So the measure needs to detect the current filter context (quarter or year) in order to return the minimum-number of reported periods. This will then be compared against the actual number of reported periods and if they match, the aggregation will be shown.
So my current approach is to count the number of months in the calender and determine the selections based on that (if 12, then year, if 3, then quarter...) but as this is on very large tables, I'm looking for performance improvements.

If there is a better solution than this approach – please tell!
 
Last edited:
Or it is simpler is this clause
Code:
measure mode:=IF(HASONEVALUE('DimTimeSeries2'[type]),
    SWITCH(DISTINCT('DimTimeSeries2'[type]),
    "sum",[Amount sum],
    "average",[Amount average],
    BLANK()
),
BLANK())
 
Last edited:
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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