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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rpinxt
Solution Sage
Solution Sage

Calculate the variance between two (variable) selections

I have this simplified view:

rpinxt_0-1714039858419.png

As you can see now LBE1 and LBE2 are selected.

I want to ad a 3rd field (measure) which will give the variance between the selections.

The slicer on the right is based on a field in the data, so each row in the data has one of these 5 in a column named 'Type'.

 

How can I make a measure that subtracts the value belonging with LBE2 with the value beloning with LBE1.

And of course if I select LBE2 and LBE3 or even LBE1 and LBE3 (LBE3, LBE4 etc etc) it still would work and subtract the values belonging to that combination.

 

5 REPLIES 5
rpinxt
Solution Sage
Solution Sage

Thanks @Anonymous but you made a "fixed" solution where you compare LBE2 with LBE1, but the user can make every selection from the slicer. So also LBE3 with LBE1 or LBE2 with LBE3.

 

Also in your measure you are treating field addendum as a field of a table in the averagex. But it is not a table field it is a measure.

 

I compiled a sample workbook here so you can see the general setup and data (real file is much bigger and complex but these fields and relations are needed for that visual) :

https://drive.google.com/file/d/10VpjOCSx1eyqixI14mklcSlL-Cti0Y-e/view?usp=sharing

 

rpinxt_0-1714122460337.png

So I have field parameter to switch between the value fields (prmValueSelection) and a slicer for the Type in which user can select LBE1, LBE2, LBE3 etc.

 

The goal now is when 2 types are selected to get the difference in selected value of these two types.

(user should not select more then 2 but if he/she does result should just be blank, 0, error or whatever message)

 

I do not think it can be done but if somebody could find a way to achieve this that would be great.

 

rpinxt
Solution Sage
Solution Sage

Well maybe it is just not possible with the current data setup.

How would you guys do something like this?
How would your data look?

Cannot be the first one that wants to look at his data in this way?? 🤔

Anonymous
Not applicable

Hi, @rpinxt 

You can implement the calculation variance in total. I've tried adding another measure to the matrix, but that would have it in every column of the matrix:

vjianpengmsft_0-1714103750758.png

vjianpengmsft_1-1714103768861.png

As you can see, while the variance of the selected two can be successfully calculated, this will put the measure of this variance into the columns of each matrix.

Instead, you can calculate the variance for two columns in the matrix and display it in the total.

Sum of Addendum =
IF (
    NOT HASONEVALUE ( 'Table'[Type] ),
    AVERAGEX (
        'Table',
        CALCULATE ( SUM ( 'Table'[Addendum] ), 'Table'[Type] = "LBE1" )
            - CALCULATE ( SUM ( 'Table'[Addendum] ), 'Table'[Type] = "LBE2" )
    ),
    SUM ( 'Table'[Addendum] )
)

vjianpengmsft_3-1714104324351.png

You can then control your slicer options, check the two columns you want to show variance, and uncheck the other columns. I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

rpinxt
Solution Sage
Solution Sage

Maybe harder then I thought.

 

Can it not be done?

Or every other way to do this would be appreciated to.

Would think there would be somekind of formula to show variance in a matrix.

rpinxt
Solution Sage
Solution Sage

Maybe posting the underlying data will help to get this solved.

 

YearMthTypeAddendum
20241LBE1340635
20241LBE2275680
20242LBE1290012
20242LBE2287260
20243LBE1314827
20243LBE2298206
20244LBE1283520
20244LBE2321729
20245LBE1270133
20245LBE2319776
20246LBE1259413
20246LBE2319392
20247LBE1256339
20247LBE2272356
20248LBE1233174
20248LBE2252100
20249LBE1273970
20249LBE2286258
202410LBE1264020
202410LBE2253540
202411LBE1257562
202411LBE2257523
202412LBE1222870
202412LBE2223364

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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