Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IF Statement for a column not working

Hi, I am currently trying to create a column with an IF statement that returns back a 1 if true or 0 if false. The table shows every time a user has taken a sick day in their period of working and e...
  • tackytechtom's avatar
    4 years ago

    Hi Anonymous ,

     

    Thanks for the data! I think I got to a solution:

     

    I did it in two steps but both steps are already incorporated in the measure below. First, I created the column TomsRolling4Column which returns the 4 month window for each User ID (see picture above) This equals everything in the FILTER statement below (in green). Afterwards, we only need to distinct count all User IDs which have a number >= 9 in the new column (blue below). 

     

    TomsRolling4Measure = 
    CALCULATE ( 
        DISTINCTCOUNT ( Table[User ID] ),
        FILTER (
            Table,
            CALCULATE (
                SUM (Table[Sickness Amount (Days)] ),
                ALLEXCEPT ( Table, Table[User ID] ),
                DATESINPERIOD(
                    Table[Sickness Date],
                    Table[Sickness Date],
                    -4, MONTH
                )
            ) >= 9 
        )
    )

     

    Please try it and let me know if it works 🙂

     

    /Tom
    https://www.tackytech.blog/
    https://www.instagram.com/tackytechtom/