Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dataaanana
Frequent Visitor

Need help in creating a histogram from a measure

Hello! I have an [Age] measure that calculates the age of active employees given a chosen year. I'm attempting to create a histogram to show the distribution of the ages of active employees given a chosen year using this measure. Is this possible? Below is the Age measure formula used: 

Age =
VAR _selyear =
    MAX(_Calendar[Year])
VAR _age =
    CALCULATE(
        DATEDIFF(SELECTEDVALUE(hr_coredata[DOB]),DATE(_selyear, 12, 31 ), YEAR ),
        ALL(_Calendar),_Calendar[Year]<=_selyear)
RETURN
_age


I tried creating the histogram using a calculated column but since it's a calculated column, ages will not be updated if I select other years.

I tried categorizing the ages of all active employees given a selected year using the formula below but I'm not really sure how I can used this in creating my histogram:

Age Category =
VAR _age = [Age]  // Assuming [Age] is the name of your existing Age measure

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+"
)

Please help! Thank you so much.Screenshot 2023-11-20 214046.png





1 REPLY 1
lbendlin
Super User
Super User

Not possible.  You need to have a disconnected age bucket table that would feed your X axis and then have your measure run against each bucket. Then let the visual do the sorting for you.

 

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors