Forum Discussion

dataaanana's avatar
dataaanana
Frequent Visitor
2 years ago

Need help in creating a histogram from measures

Hello! I'm currently really struggling on how I can create my desired output, kindly share your insights please.

I have an [Age] measure and [Age Category] measure. Is there a way for me to group and count all the employees based on their age category? I want to create a histogram that will group or count all my employees based on the following age categories:

• Under 25
• 25-34
• 35-44
• 45-54
• 55+

1 Reply

  • thats simple.

    Create new column for the age categories;
    Age Category =
    VAR Age = 'Employee'[Age]
    RETURN
    SWITCH(
    TRUE(),
    Age < 25, "Under 25",
    Age >= 25 && Age <= 34, "25-34",
    Age >= 35 && Age <= 44, "35-44",
    Age >= 45 && Age <= 54, "45-54",
    Age >= 55, "55+",
    BLANK()
    )

    Now create new column for sorting the above categories:
    Age Category Serial Number =
    VAR AgeCategory = 'Employee'[Age Category]
    RETURN
    SWITCH(
    AgeCategory = "Under 25", 1,
    AgeCategory = "25-34", 2,
    AgeCategory = "35-44", 3,
    AgeCategory = "45-54", 4,
    AgeCategory = "55+", 5,
    BLANK()
    )

     

    Click on Age Category column and go to home tab then click on sort by and now click on - Age Category Serial Number.

    now use the new column Age Category  in your histogram on y axis, and sort your y axis by Age Category column in ascending.(click on funnel icon on top right corner of the visual).

    and done.

    If this helped, Please Subscribe AnalyticPulse on YouTube for future updates:
    https://www.youtube.com/@AnalyticPulse
    https://instagram.com/analytic_pulse
    https://analyticpulse.blogspot.com/

    Please subscribe CogniJourney On Youtube For fun facts:
    https://www.youtube.com/@CogniJourney