Forum Discussion
Dynamic Column calculation based on Slicer Selection
- Anonymous9 years ago
Hi LeranPowerBI
Try the following
1. Create a table called MonthTable consisting of only MonthNames
MonthNames
Jan
Feb
.....
Dec
2. Use this Column MonthName from this MonthTable as a slicer for selecting month.
3. In your data table create a measure called SelectedMonthValue
SelectedMonthValue = IF(HASONEFILTER(MonthTable[MonthName]),
LOOKUPVALUE((YourTable[Amount]),YourTable[Month],Values(MonthTable[MonthName]))
,1)What this does is finds the value of Amount from YourTable ( data table) for the selectedmonth in the slicer. If no value is selected in slicer it is set to 1.
4. Now the magic
Create a measure called Relative in YourTable.
Relative = SUMX(YourTable,Divide(YourTable[Amount],[SelectedMonthValue]))
What this does is it iterates YourTable row by row and then calculates the relative value for that row.
Sample screen shot with the data provided by you
If this solves your issue, please accept it as a solution and also give KUDOS.
Cheers
CheenuSing
Hi sieed
Please share the data and the output desired to work out a possible solution.
Cheers
CheenuSing
Anonymous, here's thed question I posted : https://community.powerbi.com/t5/Desktop/Dynamically-compute-a-calculated-column-based-on-date-slicer/m-p/164093#M71538