Forum Discussion

ianyyz's avatar
ianyyz
Helper I
2 years ago
Solved

MEasure to take difference

 
 
highlighted 1786 in the pivot as an example
trying to see if its possible to take the difference between grand total of 118 minus the amount for that security ID found in the "summary" tab (table 1)
 
 
if i were doing this via formulas, id do a lookup based on security ID and return column A of the "summary" tab...then have another column take the difference between the lookup column and the grand total column
 
 
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi ianyyz ,

    Assume that you have two tables 'pivot' and 'summary' in Power BI, you can follow the steps below to get it:

    1. Create a calculated column in the table 'pivot'

    Column =
    VAR _amount =
        CALCULATE (
            SUM ( 'summary'[Amount] ),
            FILTER ( 'summary', 'summary'[sec id] = 'pivot'[sec id] )
        )
    RETURN
        'pivot'[Grand Total] - _amount

    2. Or create a measure as below and create a table using the field 'pivot'[sec id] and this new measure

    Measure  =
    VAR _amount =
        CALCULATE (
            SUM ( 'summary'[Amount] ),
            FILTER ( 'summary', 'summary'[sec id] = SELECTEDVALUE ( 'pivot'[sec id] ) )
        )
    RETURN
        SUM ( 'pivot'[Grand Total] ) - _amount

    Best Regards

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ianyyz ,

    Assume that you have two tables 'pivot' and 'summary' in Power BI, you can follow the steps below to get it:

    1. Create a calculated column in the table 'pivot'

    Column =
    VAR _amount =
        CALCULATE (
            SUM ( 'summary'[Amount] ),
            FILTER ( 'summary', 'summary'[sec id] = 'pivot'[sec id] )
        )
    RETURN
        'pivot'[Grand Total] - _amount

    2. Or create a measure as below and create a table using the field 'pivot'[sec id] and this new measure

    Measure  =
    VAR _amount =
        CALCULATE (
            SUM ( 'summary'[Amount] ),
            FILTER ( 'summary', 'summary'[sec id] = SELECTEDVALUE ( 'pivot'[sec id] ) )
        )
    RETURN
        SUM ( 'pivot'[Grand Total] ) - _amount

    Best Regards