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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors