Forum Discussion
calculate minimum and maximum percentage
How do I calculate minimum and maximum percentage?
Use the following table structure:
Item Name, Pass Dies, Total Dies
Percentage = Pass Dies / Total Dies x 100
Any help would be appreciated. Thanks
4 Replies
- austinsense
Impactful Individual
I think what you're asking is "How do I calculate the min and max percentage across the items?". Answering this question requires doing a calculation for every item and then bringing back the final result - for example, calculate the percentage for each product and then tell me which percentage is the lowest? Fortunately this isn't super hard if you understand the "X" functions.
Here's what you're looking for ...
MinItem% = MINX( ALL( Items ), Percentage ) MaxItem% = MAXX( ALL( Items ), Percentage )
The "X" functions take a table as the first argument, and the function is going to do a calculation for every row in that table. In this case we want to do a calculation for the items. I included the ALL function to force the calculation to look at ALL the items in the table (ignoring any filtering that's going on). The second argument in the "X" function is the expression you want to evaluate for each row - in this case, %.
Maybe you don't want to calculate the min/max based on the items, if that's the case just replace the items table with the table that you want to iterate over.
Hope this helps,
Austin
- javedbh
Helper II
austinsense Thanks for the reply but I'm not sure how to implement it.
Here is my data:
Item Name Pass Dies Total Dies Date Added Item A 50 70 28-Jan-16 Item A 70 90 12-Feb-16 Item A 115 145 15-Feb-16 Item A 230 300 27-Feb-16 Item A 18 50 10-Mar-16 Item A 67 100 17-Mar-16 Item B 68 150 12-Feb-16 Item B 119 200 27-Feb-16 Item B 268 400 17-Mar-16 Item B 742 1000 28-Mar-16 Item C 54 80 28-Jan-16 Item C 75 100 12-Feb-16 Item C 128 150 28-Mar-16 Item C 34 70 29-Mar-16 Item C 79 100 8-Apr-16 I want two things:
- Overall min and max percentage
- Item-wise min and max percentage
I creaed following measures:
Percentage = DIVIDE(SUM(ItemDetails[Pass Dies]), SUM(ItemDetails[Total Dies]), 0) * 100
Max 1 = MAXX( ALL( ItemDetails ), [Percentage] )
Max 2 = MAXX( ALL( ItemDetails ), DIVIDE(SUM(ItemDetails[Pass Dies]), SUM(ItemDetails[Total Dies]), 0) * 100 )
Max 3 = MAXX( ALL( ItemDetails[Item Name]), [Percentage] )
Max 4 = MAXX( ALL( ItemDetails[Item Name]), DIVIDE(SUM(ItemDetails[Pass Dies]), SUM(ItemDetails[Total Dies]), 0) * 100Measure "Max 1" gives the correct overall max percentage. But all other results are incorrect. BTW can you explain how these measures (Max 1,2,3,4) are working?
A screenshot is attached that shows how I configured the chart:
Sorry for any inconvenience. Thanks.
- austinsense
Impactful Individual
You're off to a great start! Two things ...
1. You need to use the query editor to create an items table that has one row for every item
- Duplicate the Item Details Query
- Remove all columns except the Item Name
- Remove Duplicates on the Item Name
- Load to Data Model & Create a Relationship between the new "Item" table and the "Item Details" table
- Replace Item Details with Item in your formulas (you'll only need formulas 1 & 2)
2. Write your "DIVIDE(SUM ..." measure separately and then reference it in the MAX measure.
I'm tied up all day but I'm sure you can figure this out with the help of other people on the forum and the internet.