Forum Discussion
Attrition Dashboard - Tenure wise
- 7 years ago
hi, karlosdsouza
First, you should know that calculated column and calculate table can't be affected by any slicer. you could create a measure instead of column.
Notice:
1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.
here is reference:
https://community.powerbi.com/t5/Desktop/Different-between-calculated-column-and-measure-Using-SUM/t...
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/Second, try this way as below:
Step1:
Add a date table as a slicer
Step2:
Use this formula to create a
Measure = VAR _tenure = IF ( SELECTEDVALUE ( Table1[Status] ) = "Active", CALCULATE ( SUMX ( Table1, CALCULATE ( ( MAXX('Date',SELECTEDVALUE('Date'[Date],NOW())) - SUM ( Table1[joining date] ) ) / 30 ) ) ), CALCULATE ( SUMX ( Table1, CALCULATE ( ( SUM ( Table1[leaving date] ) - SUM ( Table1[joining date] ) ) / 30 ) ) ) ) RETURN _tenureStep3:
Create a group table
Step4:
Use these formulae to create the result measure
HC = var _table=FILTER(GENERATE(table1,table2),[Measure]>Table2[Start]&&[Measure]<=Table2[End]) return COUNTAX(_table,[Kind])+0
Attrition = var _table=FILTER(GENERATE(table1,table2),[Measure]>Table2[Start]&&[Measure]<=Table2[End]) return COUNTAX(FILTER(_table,[Status]="Left"),Table2[Kind])+0
Result:
Note: you could use date field as a slicer or create other fields eg. year-month in date table then use it as a slicer.
And here is pbix file, please try it.
Best Regards,
Lin
hi, karlosdsouza
tenure wise attrition % is based on another table visual and measure is "tenure"
By the way: there is a little bit of modification in my pbix file, for date table it should be a full date. Use this formula to create a date table
Date = CALENDAR(DATE(YEAR(MIN(Table1[joining date])),1,1),DATE(YEAR(TODAY()),12,31))
and for the slicer, you should filter one day as a filter.
Otherwise, if you select a period of time, how to calculate the measure.
Best Regards,
Lin
Thanks ! Understood
If i make a new real table instead of virtual table. Will it make a difference v-lili6-msft ?
Also if the selected value is less than Date of Joining, the tenure will come to be negative. How do we treat that ?