Forum Discussion
Indices calculation with dynamic variable
- 3 years ago
Hey Anonymous,
One solution I will try is to have multiple columns calculated based on the years range and use a DAX measure to select the appropriate column to display based on the year selected but it will need to be unlinked from everything else.
VAR Yearbase = 2018My intention, originally, was to have this number to be variable and not fixed.
Thanks for the feedback, I will leave the topic open for a couple of weeks and then accept your solution if nothing better shows up!
Hi breeze87 ,
According to your description, would you like to implement manual entry or select a certain year to filter your new columns?
For your problem, if you need to use slicers for filtering, then you can't use a new column, you should put the columns you need on top of the visual, and then write measures based on your logic, instead of calculated columns, which can't dynamically recognize slicer filtering. Second, you can also use the MAX() function to get the value selected by your slicer and apply it to your measure.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- breeze873 years agoFrequent Visitor
Hey Anonymous,
One solution I will try is to have multiple columns calculated based on the years range and use a DAX measure to select the appropriate column to display based on the year selected but it will need to be unlinked from everything else.
VAR Yearbase = 2018My intention, originally, was to have this number to be variable and not fixed.
Thanks for the feedback, I will leave the topic open for a couple of weeks and then accept your solution if nothing better shows up!
- Anonymous3 years agoNot applicable
Hi breeze87 ,
Calculated columns are not dynamically aware of slicer filtering, try changing to a measure. and create a year table, create a slicer with the year table, change the variable to var Yearbase=selectedcolumn('for slicer',"Year",[Year]), and change the filter in the measure to FILTER( f_Feedstocks, f_Feedstocks[Year] In Yearbase ).
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- breeze873 years agoFrequent Visitor
The Index page already has a Yearly slicer to show different timeframes.
I think it would defeat the highlited slicer purpose, so I went with the approach mentioned in my first reply. With the extra table to use as a slicer like you mentioned.
Index Calc new = SWITCH( TRUE(), SELECTEDVALUE( 'Index Year'[Year] ) = 2018, CALCULATE( AVERAGEX( f_Feedstocks, f_Feedstocks[Index Jan 2018 100] ), FILTER( f_Feedstocks, f_Feedstocks[View] <= [Selected View] ) ), SELECTEDVALUE( 'Index Year'[Year] ) = 2019, CALCULATE( AVERAGEX( f_Feedstocks, f_Feedstocks[Index Jan 2019 100] ), FILTER( f_Feedstocks, f_Feedstocks[View] <= [Selected View] ) ), SELECTEDVALUE( 'Index Year'[Year] ) = 2020, CALCULATE( AVERAGEX( f_Feedstocks, f_Feedstocks[Index Jan 2020 100] ), FILTER( f_Feedstocks, f_Feedstocks[View] <= [Selected View] ) ), SELECTEDVALUE( 'Index Year'[Year] ) = 2021, CALCULATE( AVERAGEX( f_Feedstocks, f_Feedstocks[Index Jan 2021 100] ), FILTER( f_Feedstocks, f_Feedstocks[View] <= [Selected View] ) ) )hopefully the extra calculated columns don't affect the performance too much 🙂
Thanks for the help Anonymous