Forum Discussion
Anonymous
5 years agoNot applicable
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 ...
- Anonymous5 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.
Anonymous
5 years agoNot applicable
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.