Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Employee Count with Different Versions and Dates

Hi, I am trying to normalize some outside data and there are basically duplicate values for most of 2024 and some of 2023 so I need to be able to use the Agg Type of V2 if present and greater than 1...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

     

    Thanks for the reply from smpa01 .

     

    In my understanding, your requirement is to return the Resolved Count of V2 if there is more than one value for the same year and month, otherwise return the Resolved Count of V1. am I understanding correctly?

     

    Although your date column only has year and month, powerbi may recognize different days, for example, February automatically recognizes the 23rd and 24th.

     

    Therefore, you need to create a new Year Month column:

    Year Month = FORMAT('Table'[Report Date],"yyyy-mm")

     

    Create a sort column so that the Year Month column is sorted by this column:

    Year Month Sort = YEAR('Table'[Report Date])*12+MONTH('Table'[Report Date])

     

    Create a Measure that counts the number of each Year Month column:

    Count = 
    CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Year Month]))

     

    Creates a Measure and returns the Resolved Count of V2 for the same date if count>1, otherwise returns the Resolved Count of V1:

    Measure 2 = IF(
        [Count] > 1,
        CALCULATE( MAX ( 'Table'[Resolved Count] ), ALLEXCEPT('Table','Table'[Year Month]), 'Table'[AggType] = "V2"  ),
        CALCULATE ( MAX ( 'Table'[Resolved Count] ), ALLEXCEPT('Table','Table'[Year Month]) , 'Table'[AggType] = "V1")
    )

     

    The final page result is shown below:

     

    The pbix file is attached.

     

    If you have other questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!