Forum Discussion
Column Header Name in Calculation
Hi,
Is it possible to lookup the column header’s name in a calculation.
If I assign the column header a value based on its name, January 2019 could be assigned the value of 1, Feb-19 would be 2 and so forth. This way I can compare a month-year value system to replace values. To further elaborate on my end goal below see the if statement below.
If(Headername = “Jan-19”, 1, 0) or use a switch statement.
Then: if(2>1, 150,0)
With 2 being Feb-19.
6 Replies
- MFelixSuper User
Hi Anonymous,
What is the exact purpose of this can you share some sample and/or example of expected result?
One way would be to do a unpivot of the columns and then make the IF statement on that column, but not really sure what you want to achieve.
Regards,
MFelix
- AnonymousNot applicable
If we unpivot the data it creates duplicates due to an employee status column. For every month of the year we want to assign a value to it from 1-12 based off the column name. January is 1, February is 2 and so on.
- MFelixSuper User
Hi Anonymous,
Don't understand why you need to do this, can you please elaborate a little better (sorry for insisting).
Each column as a unique name so you can make calculation based on those names and no need to have new names. What I mean is that if you want to calculate the number of people with status Active in February vs January you need to create something like this:
Active Variation = CALCULATE ( COUNT ( Table[Jan-1] ); FILTER ( ALLSELECTED ( Table[Jan-19] ); Table[Jan-19] = "Active" ) ) - CALCULATE ( COUNT ( Table[Jan-1] ); FILTER ( ALLSELECTED ( Table[Feb-19] ); Table[Feb-19] = "Active" ) )Since I don't know your data and expected result is difficult to give more help but just trying to understand why you need to change the name of the columns.
Regards,
MFelix