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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculate delta between values in column based on value in another column

Hi,

 

I have a table that look like this (Table1):

 

TagVersionIDValue
A11,5
B12,1
C14,5
A21,1
B21,4
C22,3
A33,1

 

And another table that also contains of the Version column (Table2):

 

DateVersionID
1.1.20191
1.1.20202
1.1.20213

 

Since I want to use two slicers to select the VersionIDs I created two copies of Table2 - they are Table21 and Table22, and of course there is a relationship between the VersionID columns.

 

What I would like to do is to get for each Tag the delta between the values in the "Value" column, based on the VersionID (the user should always select two versions via two slicers in my report to get the deltas), so having selected VersionID 1 and VersionID 2 I want to display in my report a table like this:

 

Tagprop_delta
A0,4
B0,7
C2,2

 

I thought this would be a rather trivial problem, however I'm just not able to get it to work.

 

What I have so far is the following DAX for my measure: 

 

 

prop_delta =
var selected_verID1 = SUMMARIZE(FILTER(Table21,Table21[VersionID] IN ALLSELECTED(Table21[VersionID])),Table21[VersionID])
var selected_verID2 = SUMMARIZE(FILTER(Table22,Table22[VersionID] IN ALLSELECTED(Table22[VersionID])),Table22[VersionID])
RETURN

 

This gives me correctly the VersionIDs that were selected. So for the rest of my calculation I was hoping that soemthing like that should do the job:

 

CALCULATE(SUMX(FILTER(Table1, Table1[VersionID] =selected_verID1), Table1[Value])-SUMX(FILTER(Table1, Table1[VersionID] =selected_verID2), Table1[Value]))

 

However this doesn't work at all and only creates a "A table of multiple values was supllied where a single value was expected" error.

 

Thanks for any help!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Ok - I finally fixed it by simply creating a new measure and copying my code into this new measure. Now it works - so I guess the error was just a bug.

View solution in original post

5 REPLIES 5
PaulOlding
Solution Sage
Solution Sage

Assuming your model looks something like this

PaulOlding_3-1620579282737.png

 

then a prop_delta measure like this

PaulOlding_4-1620579956151.png

 

 

Gives a result like this

PaulOlding_2-1620579243550.png

 

 

 

Anonymous
Not applicable

Hi Paul,

 

thanks for your advice - however this still gives me the "A table of multiple values was supllied where a single value was expected" error.

Anonymous
Not applicable

Ok, In the meantime I did find a relatively simple solution myself which works as long as I only use one var in it (so either selected_verID1 or selected_verID2 has to be replaced by a static number). This works:

 

 

prop_delta =
var selected_verID1 = SUMMARIZE(FILTER(Table21,Table21[VersionID] IN ALLSELECTED(Table21[VersionID])),Table21[VersionID])
var selected_verID2 = SUMMARIZE(FILTER(Table22,Table22[VersionID] IN ALLSELECTED(Table22[VersionID])),Table22[VersionID])
RETURN
CALCULATE(CALCULATE(SUMX(FILTER(Table1, Table1[VersionID] =selected_verID1), Table1[Value]))-CALCULATE(SUMX(FILTER(Table1, Table1[VersionID] = 3), Table1[Value])))

 

 

.....but if I replace the "3" in the second FILTER by selected_verID2 I get again the same error. Can anyone tell me what's the issue here?

Anonymous
Not applicable

Ok - I finally fixed it by simply creating a new measure and copying my code into this new measure. Now it works - so I guess the error was just a bug.

Anonymous
Not applicable

daxer_0-1620387916077.pngdaxer_1-1620388052438.png

daxer_2-1620388158157.pngdaxer_3-1620388205999.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.