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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
unique-user-nam
New Member

Create dynamic measure comparing value in each row against context-based average

Hi there, new to the forum and DAX here.

I'm trying to create, for each store in a row, a measure named [Ranks] that compares 'cleaned'[TO Efficiency] and 'cleaned'[OCR] with the respective context-based averages, i.e. if I apply filters, the measure values change based on the filtered data as well. 

Ranks = SWITCH(
    TRUE(),
    cleaned[TO Efficiency] < cleaned[Avg_TO_Eff] && cleaned[OCR] > cleaned[Avg_OCR], "1",
    cleaned[TO Efficiency] < cleaned[Avg_TO_Eff] && cleaned[OCR] < cleaned[Avg_OCR], "2",
    cleaned[TO Efficiency] > cleaned[Avg_TO_Eff] && cleaned[OCR] > cleaned[Avg_OCR], "3",
    cleaned[TO Efficiency] > cleaned[Avg_TO_Eff] && cleaned[OCR] < cleaned[Avg_OCR], "4"
)

The above code, although produces one single value which is not what I want (my understanding is it's calculating for the entire table instead of for each row), illustrates what I want to achieve.

uniqueusernam_0-1669715042108.png

Eventually I want to assign 4 diffrent colors that change according to filter context to the bubbles scattered in four different quadrants delineated by the two averages.  

 

Any tips would be greatly appreciated. Thanks!

2 REPLIES 2
Anonymous
Not applicable

Hi @unique-user-nam ,

 

I think you should use a new column instead of a new measure.

 

Best Regards,
Shreya Mukkawar

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

Thanks for the reply! But aren't values in a column static? Will they recalculate if I apply filtered? 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.