Forum Discussion

LauraBueno's avatar
LauraBueno
Helper III
6 years ago
Solved

Use measure in FILTER function

Hi,   I'm trying to use the FILTER function to create a subtable based on the value of one of the columns. when I input a scalar value directly is working, however, when using the vlaue from a calc...
  • MartynRamsden's avatar
    MartynRamsden
    6 years ago

    Hi LauraBueno 

     

    You'll need to create a disconnected slicer - this is a slicer that won't filter other visuals in your report.

     

    To do this, you need create a new table using the following DAX expression:

    DisconnectedTable = ALL ( 'db_datareader Simulation'[Study], 'db_datareader Simulation'[Simulation] )

     

    Then create the following measures:

    Total Value = SUM ( 'db_datareader Simulation'[Value] )
    Delta = 
    VAR Sim_Ref = SELECTEDVALUE ( DisconnectedTable[Simulation] )
    VAR Value_Ref = 
    CALCULATE ( 
        SUM ( 'db_datareader Simulation'[Value] ),
        'db_datareader Simulation'[Simulation] = Sim_Ref
    )
    VAR SumVal = [Total Value]
    VAR Result = SumVal - Value_Ref
    RETURN Result

     

    In your report, add two slicers:

    1. 'db_datareader Simulation'[Study]
    2. 'DisconnectedTable'[Simulation]

     

    Then add a table visualisation with the following columns from the 'db_datareader Simulation' table:

    • Study
    • Simulation
    • Type
    • Value
    • [Delta] measure

     

    You'll find that your Simulation slicer won't automatically filter depending on your selection in the Study slicer.

    If you want this to work, you can create the measure below and add it to the Simulation slicer as a visual filter and set the value to 1.

     

    SlicerFilter = 
    VAR SelStudy = SELECTEDVALUE ( 'db_datareader Simulation'[Study] )
    VAR SimStudy = SELECTEDVALUE ( DisconnectedTable[Study] )
    VAR Result = 
    IF ( 
        SimStudy = SelStudy,
        1,
        0
    )
    RETURN Result

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    This is the result I got using the data you provided:

     

     

     

     

     

     

     

     

     

     

     

     

     

    Fingers crossed, this will work for you!

     

    Best regards,

    Martyn