cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

Unit Price Best = MINX(FILTER(ALLSELECTED(Sheet1),Sheet1[INTERNAL_ITEM_CODE]=SELECTEDVALUE(Sheet1[INTERNAL_ITEM_CODE])),Sheet1[Unit Price])

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]
return
IF(HASONEFILTER(Sheet1[INTERNAL_ITEM_CODE]),
CALCULATE(SUMX(Sheet1,Sheet1[Total]-(Sheet1[Quantity]*UP))),
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]
RETURN
CALCULATE(LASTNONBLANK(Sheet1[SUPPLIER_NAME],Sheet1[SUPPLIER_NAME]),Sheet1[Unit Price]=best,ALLEXCEPT(Sheet1,Sheet1[INTERNAL_ITEM_CODE]),ALL(Sheet1[SUPPLIER_NAME]))

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]

RETURN

SWITCH(TRUE(),
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",
"Other")

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.

4 REPLIES 4
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.

Super User

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User

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

Regards

Miguel Félix

Proud to be a Super User!

Check out my blog: Power BI em Português

Super User

Hi

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

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors