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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
PowerAuto82
Helper II
Helper II

Calculated Column on a Measure not returning correct values

Hi,

 

I previously raised the following question

https://community.powerbi.com/t5/Desktop/Dynamic-Calculate-Age-at-point-of-time-date-selection/m-p/2...

 

Based on the Age DAX measure that was provided to me on the Accepted solution, I created a new Calculated Column  as per below, but all the results are coming back of a value of -20 and not sure why?

 

 

Age Range = 
    IF('Employee'[Age] < 20, "-20",
        IF('Employee'[Age] >=20 && 'Employee'[Age] <=30, "20-30",
            IF('Employee'[Age]>30 && 'Employee'[Age] <=40,"31-40",
                IF('Employee'[Age]>40 && 'Employee'[Age] <=50,"41-50",
                    IF('Employee'[Age]>50 && 'Employee'[Age] <=60,"51-60","61+")))))

 

 

The reason I want this as a calculated column because I want to use this within a Clustered Column Chart for the X-axis

 

Thanks

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@PowerAuto82 you cannot convert measure to a conditional column, You need a disconnected table and then use that for visual, check this blog post on dynamic segmentation  Dynamic segmentation – DAX Patterns

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

I made a change to the current DAX to the below

 

Age 2 = 
AVERAGEX (
    VALUES ( 'Calendar'[Date].[Year] ),      
    VAR EmployeeInSegment =                
        FILTER ( 
            ALLSELECTED ( Employee ),
            VAR AgeOfEmployee = [Age] 
            VAR SegmentForEmployee =             
                FILTER (                         
                    'Age Band Desc',
                    NOT ISBLANK ( AgeOfEmployee )
                        && 'Age Band Desc'[Start] <= AgeOfEmployee
                        && 'Age Band Desc'[End] >= AgeOfEmployee8
                )
            VAR IsCustomerInSegments = NOT ISEMPTY ( SegmentForEmployee )
            RETURN IsCustomerInSegments
        )
    VAR Result =
        CALCULATE (
            [Age],                     
            KEEPFILTERS ( EmployeeInSegment )  
        )
    RETURN Result
)

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@PowerAuto82 keep the measure, you need a new table with the range and then use that as described in the blog post.

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I made a change to the current DAX to the below

 

Age 2 = 
AVERAGEX (
    VALUES ( 'Calendar'[Date].[Year] ),      
    VAR EmployeeInSegment =                
        FILTER ( 
            ALLSELECTED ( Employee ),
            VAR AgeOfEmployee = [Age] 
            VAR SegmentForEmployee =             
                FILTER (                         
                    'Age Band Desc',
                    NOT ISBLANK ( AgeOfEmployee )
                        && 'Age Band Desc'[Start] <= AgeOfEmployee
                        && 'Age Band Desc'[End] >= AgeOfEmployee8
                )
            VAR IsCustomerInSegments = NOT ISEMPTY ( SegmentForEmployee )
            RETURN IsCustomerInSegments
        )
    VAR Result =
        CALCULATE (
            [Age],                     
            KEEPFILTERS ( EmployeeInSegment )  
        )
    RETURN Result
)
parry2k
Super User
Super User

@PowerAuto82 you cannot convert measure to a conditional column, You need a disconnected table and then use that for visual, check this blog post on dynamic segmentation  Dynamic segmentation – DAX Patterns

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k 

 

I have added the file linke to one drive below which has the new measure and table.

 

https://1drv.ms/u/s!AkzJiHUi2WtQfeq6weejdmOZ1Ls?e=Fb7cc0 

 

But for some reason it is not working, when I select Year 2022 then the Employment Id Emp13 is missing?

When I select Year 2021 then the Employment Id Emp06 is missing

When Year 2019 or 2020 is either selected it seems to work fine, any ideas?

 

Hi @parry2k 

Would you know where to start? Would I have to change the current DAX Measure I have for Age or keep that and create a new measure? Or do I just need to create a new table that holds the Age Range?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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