Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Subtract Values Based on Two Slicer Selections

I am working with survey response data.  I have data for different years (in same format) and data for different org codes.  I can currently select multiple org codes from slicer to see the data, but I would like to add a column to subtract the difference based on the selected slicers so I can see which orgs did better than the others.  But I can't figure it out.   

 

New Power Bi user and I would great appreciate your help as I am learning how to use the program. 

My fields are Org (ST10, ST11, ST12, etc), Pos (this is the value), Date, & Quest #.  Here's snapshot of my data:

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    Please have a try.

    Create 2 tables, then put the field into the slicer.

    slicera=summarize('table','table'[Org])
    slicerb=summarize('table','table'[Org])

    Create a measure.

     

    Difference in Pos =
    var _selecteda=selectedvalue(slicera[org])
    var _selectedb=selectedvalue(slicerb[org])
    VAR Org1Value =
        CALCULATE ( SUM ( 'Table'[Pos] ), 'Table'[Org] =_selecteda )
    VAR Org2Value =
        CALCULATE ( SUM ( 'Table'[Pos] ), 'Table'[Org] =_selectedb )
    RETURN
        Org1Value - Org2Value
    

     

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

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

     

     

     

     

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Please have a try.

    Create 2 tables, then put the field into the slicer.

    slicera=summarize('table','table'[Org])
    slicerb=summarize('table','table'[Org])

    Create a measure.

     

    Difference in Pos =
    var _selecteda=selectedvalue(slicera[org])
    var _selectedb=selectedvalue(slicerb[org])
    VAR Org1Value =
        CALCULATE ( SUM ( 'Table'[Pos] ), 'Table'[Org] =_selecteda )
    VAR Org2Value =
        CALCULATE ( SUM ( 'Table'[Pos] ), 'Table'[Org] =_selectedb )
    RETURN
        Org1Value - Org2Value
    

     

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

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