Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dynamically update column values based on maximum slicer Date

Hi everyone I have the following task, which i am pulling my hairs for several hours Attached is the PBIX File   I have requirement to display data in Matrix and update "Opening Balance" calculat...
  • v-piga-msft's avatar
    7 years ago

    Hi Anonymous ,


    I have requirement to display data in Matrix and update "Opening Balance" calculated Column based on following rules

     

    1. If max slicer date is greater than Acquisition date, than "Opening balance" = sum (Acquisition Price + Acquisitions added – Depreciations Added – Write downs)
    2. But if max slicer date is same as acquisition date, "Opending balance" = only (Acquistion price)
    3. Hide rows if acquisition date is greate than the slicer date range

     

    From your pbix, it seems that you create the calculated column for Opening Balance, you'd better create the measure which is dynamic.

     

    You could try the measure below based on your logic.

     

    Measure =
    VAR a =
        CALCULATE ( MAX ( 'Date'[Date] ), ALLSELECTED ( 'Date' ) )
    VAR b =
        MAX ( 'Query1'[ACQUISITIONDATE] )
    RETURN
        IF (
            a = b,
            SUM ( 'Query1'[ACQUISITIONPRICE] ),
            IF (
                a > b,
                SUM ( 'Query1'[ACQUISITIONPRICE] ) + SUM ( 'Query1'[Acquisition_Add] )
                    - SUM ( 'Query1'[Depreciation_Add] )
                    - SUM ( 'Query1'[Writedown_Add] )
            )
        )
    

    Here is the output.

     

     

    Best  Regards,

    Cherry