Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Get single value using VAR from multiple value options

Hi   Can anyone help me write a full code?     Step1. Try to get value from below data source first.   Table name: GR - 5G SvC_master ~ 2022 - Previous Backup Data Column name for value to fe...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.  

    (2) We can create a calculated column.

    GR Date =
    VAR _a =
        LOOKUPVALUE (
            'GR - 5G SvC_master ~ 2022 - Previous Backup Data'[GR Date],
            'GR - 5G SvC_master ~ 2022 - Previous Backup Data'[Site], [Internal Site ID]
        )
    VAR _max_index =
        CALCULATE (
            MAX ( 'GR - 5G SvC_master since 2023 - Current Monthly Data'[Index] ),
            FILTER (
                'GR - 5G SvC_master since 2023 - Current Monthly Data',
                [Site] = EARLIER ( 'Distinct - Master Data'[Internal Site ID] )
            )
        )
    VAR _b =
        CALCULATE (
            MAX ( 'GR - 5G SvC_master since 2023 - Current Monthly Data'[GR Date] ),
            FILTER (
                'GR - 5G SvC_master since 2023 - Current Monthly Data',
                [Site] = EARLIER ( 'Distinct - Master Data'[Internal Site ID] )
                    && [Index] = _max_index
            )
        )
    RETURN
        IF ( ISBLANK ( _a ), _b, _a )
    

    (3) Then the result is as follows.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.