Forum Discussion

PowerAuto82's avatar
PowerAuto82
Helper II
3 years ago
Solved

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/2789509#M967469   Based on the Age DAX measure...
  • parry2k's avatar
    3 years ago

    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  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.

     

     

  • PowerAuto82's avatar
    PowerAuto82
    3 years ago

    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
    )