Forum Discussion

karlosdsouza's avatar
karlosdsouza
Icon for Helper II rankHelper II
7 years ago
Solved

Attrition Dashboard - Tenure wise

Generally, in attrition analysis - an important leg is "Tenure wise attrition" to analyse which tenure people are moving out at a more / less rate.   The data that i have is as below: List of all ...
  • v-lili6-msft's avatar
    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
        _tenure

    Step3:

    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