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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Frequent Visitor

Dynamic Categorization of data based on measures

Hello All,


I'm trying to determine the cheapest price paid for each item and then based on certain criteria bucket the potential savings into different categories.  I've been able to get most of everything I need, however I can only get the categorization to work at the lowest level and not when the data is aggregated.  I know I'm missing something very basic but I can't for the life of me figure it out.  Any help would be immensley appreciated.  


I put together a sanitized and simplistic example of the actual dataset.  


We begin with this basic structure



I use a measure to determine the lowest price for each item - @MFelix was awesome enough to help with




Then this measure determines how much we would have theoretically saved had we purchased at the lowest price

Unit Price Opportunity =
var UP = [Unit Price Best]
CALCULATE(SUM(Sheet1[Total])-[Unit Price Best Total])

This measure determines who the lowest priced supplier is for each item

Unit Price Best Supplier =
var best = [Unit Price Best]

All of this is working well, however if there's a better way to do any of that feel free to let me know.  The problem comes in with the final measure which attempts to bucket the potential opportunity.  If the item is cheaper from a different supplier it would say other vendor and if we're simply getting the item cheaper from the same vendor it would say Price Parity


Unit Price Best Opportunity Type 2 =
var best = [Unit Price Best]
var bs = [Unit Price Best Supplier]


SELECTEDVALUE(Sheet1[Unit Price])=[Unit Price Best],"",
SELECTEDVALUE(Sheet1[SUPPLIER_NAME])=bs&&SELECTEDVALUE(Sheet1[Unit Price])>best,"Price Parity",
SELECTEDVALUE(Sheet1[SUPPLIER_NAME])<>bs&&SELECTEDVALUE(Sheet1[Unit Price])>best,"Other Vendor",



When I include the unit price field in the table it works with no issue, however when I roll it up it doesn't.  




I need to be able to show it at the level of the middle table as well as simply have a chart that shows the total opportunity by type.  


I have a PBIX setup to try and help anyone that would like to help out and will try to determine how to attach it.  

Frequent Visitor

Thank you both so much, hopefully this link should work.


I added a table entitled Expected, which simply summarizes the main table and adds the measures stated above.  Then added an expected sheet for how the expected result should work.  This would of course work for my real dataset, however based on what filters the user selects the lowest unit price may change, thus using a static intermediary table wouldn't work.  I've tried that table as a variable within the measures but just couldn't get it to work.  


One last note, the first table on the expected sheet will be a graph on the final report, but as i'm sure you know using measures for your axis labels is a whole other item.  I have that piece working fine in the final solution so for simplicity I kept this pbix to the root issue.

I have still not understood your requirement.  Someone else will help you.

Ashish Mathur
Super User
Super User

Hi @soshaughnessy7 


Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Miguel Félix

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português

Super User
Super User


I'd like to try.  Share your PBI file,  In that file, please show the expected result very clearly with a proper explanation.

Ashish Mathur

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.