Forum Discussion

Tevon713's avatar
Tevon713
Helper V
3 years ago
Solved

Switch function based on selection filter to another table value

Hi all,    Got 2 tables, I want to switch or return value in another table then use that for a measure calculation.  See below measure created, it not working.   Selected_Measure = VAR Se...
  • v-jingzhang's avatar
    v-jingzhang
    3 years ago

    Hi Tevon713 

     

    This error occurs because Table2[Region]=[Selected_Measure] portion is used as a filter expression in CALCULATE function. To avoid this error, you can try the following measure. Add a variable to get the measure value in advance, then use the value in CALCULATE. 

    Matches Count =
    VAR __value = [Selected_Measure]
    RETURN
        CALCULATE (
            DISTINCTCOUNT ( Table2[Acct Num] ),
            FILTER (
                Table2,
                LOOKUPVALUE ( Table1[Acct Num], Table1[Acct Num], Table2[Acct Num] )
            ),
            Table2[Region] = __value
        )
    

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!