Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

diffrence between 2 rows

Hi, I want to subtract the value from the year 2022 - 2021, can someone help me for creating measure so i can put the diffrence value just below the 2021,2022 row.

 

i created below measure which gives 2 years value while selecting only one year in the slicer.

YearSlicerMeasure =
var Yearselection = SELECTEDVALUE ('Date'[year])



return
if(
     (max(vw_CLG_vwMLSFlashAllData_PowerPivot_FACTS[year]) <= yearselection
&&                   
    max(vw_CLG_vwMLSFlashAllData_PowerPivot_FACTS[year]) >= yearselection - 1)
                                                                                                                                     ,1,0)
  • Hi,

    I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file whether it suits your requirement.

     

     

    New Lease Count Measure: =
    VAR _recenttyear =
        CALCULATE ( MAX ( Data[Year] ), ALL ( Data[Year] ) )
    VAR _previousyear = _recenttyear - 1
    VAR _diff =
        CALCULATE ( SUM ( Data[NewLeaseCount] ), Data[Year] = _recenttyear )
            - CALCULATE ( SUM ( Data[NewLeaseCount] ), Data[Year] = _previousyear )
    RETURN
        SWITCH (
            TRUE (),
            ISINSCOPE ( Data[Year] ), SUM ( Data[NewLeaseCount] ),
            ISINSCOPE ( Data[Month] ), _diff
        )
    

2 Replies

  • Hi,

    I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file whether it suits your requirement.

     

     

    New Lease Count Measure: =
    VAR _recenttyear =
        CALCULATE ( MAX ( Data[Year] ), ALL ( Data[Year] ) )
    VAR _previousyear = _recenttyear - 1
    VAR _diff =
        CALCULATE ( SUM ( Data[NewLeaseCount] ), Data[Year] = _recenttyear )
            - CALCULATE ( SUM ( Data[NewLeaseCount] ), Data[Year] = _previousyear )
    RETURN
        SWITCH (
            TRUE (),
            ISINSCOPE ( Data[Year] ), SUM ( Data[NewLeaseCount] ),
            ISINSCOPE ( Data[Month] ), _diff
        )
    
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, Jihwan_Kim 
      It works, Thank You for your support.