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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
anna-lee
Helper I
Helper I

Help with Avg measure

I currently have a matrix that looks like the below.

annalee_0-1669758468680.pngannalee_1-1669758537120.png

 

I'm trying to write a measure to conditional format for the measure '01 TOT' that will compare it to the average of ALL the vendors (even when the matrix is filtered) across '01 TOT' by year.

Measure would probably work up to something like the below

 

Measure = 

SWITCH(
        TRUE(),
        [01 TOT] = "","white",
        [01 TOT] < Avg ALL [01 TOT] by year, "#red",
        [01 TOT] > Avg ALL [01 TOT] by year, "#green",
        )


So ideally the average amount for 2018 '01 TOT' would be 4.53 and each individual row would compare off that number. Then CAP001 would be red, ENN001 would be green, etc.

Side note that '01 TOT' and '02 CR' are measures and not columns. The matrix has been sorted to switch values to rows.

 

Vendor CodeYear05 Total Asset Turnover06 Current Ratio
CAP0012014  
CAP0012015  
CAP0012016 1.930710612
CAP00120173.5189261592.029477196
CAP00120181.8086538811.521665604
CAP00120191.7186340521.679110985
CAP0012020  
CAP0012021  
ENN0012014  
ENN0012015  
ENN0012016 1.608867851
ENN00120174.1687809082.05808682
ENN001201811.42269761.270856779
ENN001201910.885671774.741053777
ENN001202010.647593327.671194389
ENN00120218.6026098216.18038405
GOT0012014  
GOT0012015  
GOT0012016  
GOT0012017 1.7586807
GOT00120183.525662112.124413981
GOT00120193.0699926631.662603711
GOT00120202.2331831062.756393104
GOT00120213.4023362971.783105835
HLU0012014 1.224379444
HLU00120153.2124255251.274757327
HLU00120162.7511197161.430842194
HLU00120173.3763454231.34102308
HLU00120183.1336386621.503459097
HLU00120193.1708217191.835815342
HLU00120202.4532529262.651480975
HLU0012021  
JM30012014  
JM30012015  
JM30012016  
JM30012017 3.167344818
JM300120182.2460329112.384219389
JM300120192.0639184011.950582308
JM300120202.162035632.528987681
JM30012021  
PGNY0012014  
PGNY0012015 5.021096458
PGNY00120163.9950977953.09440364
PGNY00120174.2365190593.926147286
PGNY00120185.2782909491.756153928
PGNY00120194.6363668021.624023349
PGNY00120202.5383315581.554417275
PGNY0012021  
RCA0012014  
RCA0012015  
RCA0012016 3.767709675
RCA00120175.1266477021.624707333
RCA00120184.3208683471.143674575
RCA00120192.5451086851.181451109
RCA00120201.6805879380.896006701
RCA00120212.0913988222.574800288
2 REPLIES 2
amitchandak
Super User
Super User

@anna-lee , Try like

 

Measure = 
Var _tot = [01 TOT]+0
var _all = calculate([01 TOT], allselected(Table[Vendor]) // or calculate([01 TOT], removefilters(Table[Vendor])
SWITCH(
TRUE(),
_tot = 0,"white",
_tot < _all, "#red",
_tot > _all, "#green",
)

 

 

very similar what I have done here

Scatter Quadrant -Segment in 4 quadrants based on Margin % and Discount, Use Constant Line- https://youtu.be/0k_C_E7YOQY

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak 

Your formula's weren't calculating the average. I tried both:

CALCULATE(AVERAGEX('Table',[01 TOT]),ALLSELECTED('Table'[Vendor Code]))
and 
CALCULATE(AVERAGEX('Table',[01 TOT]),ALLEXCEPT('Table','Table'[Year]))

but they both are returning the same incorrect results.

annalee_0-1669822964397.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.