Forum Discussion
Dynamically limit output columns in matrix
- 1 year ago
I have found the original DAX to work where there is a single metric, so i created two matrix tables and used bookmarks to allow for metric selection.
LesleyR , Try using
DAX
VAR _period = SELECTEDVALUE(par_period[par_period Order])
//0=day, 1=week, 2=month
VAR _metric = SELECTEDVALUE(par_metric[par_metric Order])
//count=0, percent=1
VAR _minday = CALCULATE(MAX(dimCalendar[Date]), ALLSELECTED(dimCalendar[Date])) - 98
VAR _minweekoffset = CALCULATE(MAX(dimCalendar[WeekOffset]), ALLSELECTED(dimCalendar[WeekOffset])) - 98
VAR _minsow = CALCULATE(MIN(dimCalendar[Date]), dimCalendar[WeekOffset] >= _minweekoffset)
VAR _filterdate =
SWITCH(
TRUE(),
_period = 0, _minday,
_period = 1, _minsow,
_period > 1, MIN(dimCalendar[Date]) //will never have more than 100 months in dataset
)
VAR _metric1 = CALCULATE([Metric 1], dimCalendar[Date] >= _filterdate)
VAR _metric2 = CALCULATE([Metric 2], dimCalendar[Date] >= _filterdate)
VAR _metric3 = CALCULATE([Metric 3], dimCalendar[Date] >= _filterdate)
VAR _result =
SWITCH(
TRUE(),
_metric = 0 && _period >= 0, _metric1,
_metric = 1 && _period < 1, FORMAT(_metric2, "0.0%"),
_metric = 1 && _period > 0, FORMAT(_metric3, "0.0%")
)
RETURN
_result
- LesleyR1 year agoFrequent Visitor
HI, not sure i see what is different here, can you highlight which part of the DAX you changed