Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Dynamic Age Groups - DAX

Hi, I am trying to represent the age demographic(with dynamic groups) across a workforce in DAX and I am having some trouble trying to represent it in the form of a graph.    I have the following ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    Try this measure.

    Count =
    SWITCH (
        MAX ( 'Table (2)'[Age Bracket] ),
        "18-24",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    'Table',
                    YEAR ( TODAY () ) - 24
                        <= YEAR ( [Date of Birth] )
                        && YEAR ( [Date of Birth] )
                            <= YEAR ( TODAY () ) - 18
                )
            ),
        "25-34",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    'Table',
                    YEAR ( TODAY () ) - 34
                        <= YEAR ( [Date of Birth] )
                        && YEAR ( [Date of Birth] )
                            <= YEAR ( TODAY () ) - 25
                )
            ),
        "Under 18",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER ( 'Table', YEAR ( TODAY () ) - 18 >= YEAR ( [Date of Birth] ) )
            )
    )
    

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.