Forum Discussion
Anonymous
4 years agoNot applicable
Dynamic Columns based on Slicer selection
Hello, I have below sample data with 4 Columns. Country Account Year Value AUS EBITDA 2022 13 AUS EBITDA 2023 10 AUS EBITDA 2018 98 AUS EBITDA 2021 120 AUS ...
- Anonymous4 years ago
Hi Anonymous ,
Here I suggest you to try this code to create a measure.
Measure = VAR _SELECTYEAR = SELECTEDVALUE('Table 2'[Year]) VAR _VALUE = IF( ISFILTERED('Table 2'[Year]), SWITCH( MAX('Table'[Account]), "EBITDA", CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]>=_SELECTYEAR-2&&'Table'[Year]<=_SELECTYEAR)), "Sales", CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=_SELECTYEAR)), "ITDA", CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]>_SELECTYEAR&&'Table'[Year]<=_SELECTYEAR+2)) ) ) RETURN _VALUEResult is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
4 years agoNot applicable
Hi Anonymous ,
Here I suggest you to try this code to create a measure.
Measure =
VAR _SELECTYEAR = SELECTEDVALUE('Table 2'[Year])
VAR _VALUE =
IF(
ISFILTERED('Table 2'[Year]),
SWITCH(
MAX('Table'[Account]),
"EBITDA",
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]>=_SELECTYEAR-2&&'Table'[Year]<=_SELECTYEAR)),
"Sales",
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=_SELECTYEAR)),
"ITDA",
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]>_SELECTYEAR&&'Table'[Year]<=_SELECTYEAR+2))
)
)
RETURN
_VALUE
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.