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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
bjackson2760
Helper I
Helper I

Variance column for Dynamically selected columns

Greetings,

 

I have a matix that consist of dynamic columns. The data consist of reports that are Jan-Dec.  Each month has it's own Jan thru Dec totals in each file, see below left side.  Currently I am testing Jan-Mar first.   I would like for whichever columns are selected by the user to equal a measure which is the "variance" column.  Is this possible?  See below picture.  Any assistance would be greatly appreciated.  I need a "variance" column to replace the "Total" column.

 

bjackson2760_0-1763866675635.png

 

1 ACCEPTED SOLUTION
bjackson2760
Helper I
Helper I

Thanks everyone.  I found it on another thread.  I found this code and used it, but it only worked once I have a sum total next to it.

var mmax = CALCULATE(max(DataProfile[Units]),allselected(Contacts[Name]))
var mmin = CALCULATE(min(DataProfile[Units]),allselected(Contacts[Name]))
return mmax-mmin

I will come return to give credit.  Thanks. 

View solution in original post

8 REPLIES 8
bjackson2760
Helper I
Helper I

Thanks everyone.  I found it on another thread.  I found this code and used it, but it only worked once I have a sum total next to it.

var mmax = CALCULATE(max(DataProfile[Units]),allselected(Contacts[Name]))
var mmin = CALCULATE(min(DataProfile[Units]),allselected(Contacts[Name]))
return mmax-mmin

I will come return to give credit.  Thanks. 

His user name is "Ibenlin".

lbendlin
Super User
Super User

Option 1. Remember that your measure is calculated four times in a matrix visual. Change the formula for the column totals to variance

Option 2. Alternatively consider using visual calculations.

Thank you, I will try that and get back to you.  Besides just changing the option to variance which looks crazy, it gives me zeros.

yeah, that's not going to work.  I need a variance for 2 selected months.  I'll just let him know that is the limit and makes sense.

Ashish_Mathur
Super User
Super User

Hi,

So if you have selected 3 months (as shown in the picture), then how should variance be calculated?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish.  I need a variance for 2 selected months.  I'll just let him know that is the limit and makes sense.

I am suggesting to my client that they only compare 2 at a time or do a visual.  Two is difficult enough,also it would make any sense to try to get a variance from 3 or more.  

 

Thank you, I have posed that very question to him, I am awaiting feedback. 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.