Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
TMAUND123
Regular Visitor

Dynamically Calculating Difference between two rows based on filter selected

Capture.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I currently am working on a dashboard where i need a chart to show the difference in time between multiple months (see above).

 

I have created a column using the following expression to get the difference between the row values in the AverageTimeTakenInMSPerSearch.

 

Difference = vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch] - IF(
vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch] = 0,
vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch],
LOOKUPVALUE(
vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch],
vwActivityLogSummarySearchStats[Index],
vwActivityLogSummarySearchStats[Index]-1)
)

 

However on the dashboard if i select February 2016 vs February 2017 i get the difference values 

February 2016 : -8.08938476346708
February 2017 : 1.79808856418784

 

Showing the difference as 1.7 when this is incorrect, is there a way to get this to show the correct difference based on my selection.

 

Capture1.JPG

 

Thanks

Tom

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @TMAUND123,

 

If I understand you correctly, you should be able to use the formula below to create a new measure to Dynamically Calculating Difference between two rows based on filter selected. Smiley Happy

 

Difference =
VAR minIndex =
    MIN ( vwActivityLogSummarySearchStats[Index] )
VAR maxIndex =
    MAX ( vwActivityLogSummarySearchStats[Index] )
RETURN
    CALCULATE (
        SUM ( vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch] ),
        vwActivityLogSummarySearchStats[Index] = minIndex
    )
        - CALCULATE (
            SUM ( vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch] ),
            vwActivityLogSummarySearchStats[Index] = maxIndex
        )

 

Regards

View solution in original post

1 REPLY 1
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @TMAUND123,

 

If I understand you correctly, you should be able to use the formula below to create a new measure to Dynamically Calculating Difference between two rows based on filter selected. Smiley Happy

 

Difference =
VAR minIndex =
    MIN ( vwActivityLogSummarySearchStats[Index] )
VAR maxIndex =
    MAX ( vwActivityLogSummarySearchStats[Index] )
RETURN
    CALCULATE (
        SUM ( vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch] ),
        vwActivityLogSummarySearchStats[Index] = minIndex
    )
        - CALCULATE (
            SUM ( vwActivityLogSummarySearchStats[AverageTimeTakenInMSPerSearch] ),
            vwActivityLogSummarySearchStats[Index] = maxIndex
        )

 

Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.