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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
powpowpow
Frequent Visitor

Percentage of total aggregated by category :(

Hi Everyone, 


I am new to Power BI and have not been able to figure out this problem for the last 2 weeks...

 

In order to see if an item is available at a select point of sale, I created a column that has a value of 1 if an item is in stock and 0 otherwise. (Simple measure "Availability" =  if (stock units >1, 1, 0) )

 

Now, I am interested in seeing the presence rate percentage for each item by retailer. This means that I want the numerator to be equal to the sum of "Availability" accross all point of sales (so that it totals the number of point of sales where my item is in stock, per retailer). I want the denominator to be equal to the total number of stores considered. 

 

Sample data (for one item and two retailers but there are so many)

ITEM IDRETAILERDOOR#STOCKAvailability
0151BCBBCB#0011,2001
0151BCBBCB#00200
0151BCBBCB#003151
0151BCBBCB#00400
0151BCBBCB#0055361
0151BCBBCB#0069871
0151BCBBCB#00700
0151BCBBCB#00800
0151BCBBCB#0091341
0151BCBBCB#0101,2891
0151APEAPE#0014761
0151APEAPE#0023561
0151APEAPE#00300
0151APEAPE#0041351
0151APEAPE#005121
0151APEAPE#00600

 

In this case, BCB has a total of 10 doors and APE has a total of 6 doors

 

My Dream Result is to create an availability percentage equal to (1+0+1+0+1+1+0+0+1+1)/10 = 60% for BCB and (1+1+0+1+1+0)/6 = 66.67% for APE. 

 

The problem:

Item ID, Door #, Stock Units are all in different tables. 

Retailer and Door# are in the same table

I CANT FIGURE OUT THE DAX FORMULAS TO CALCULATE THE AVAILABILITY PERCENTAGE. 

It needs to work for all items and for any retailer i select in my slicers 

Items are grouped by size (big  - medium - small) so ideally, I can filter on the size category and still get the availability percentage. (size is in the same table as item)

 

I know that its a lot of info but need help from the pbi community. SAVE ME PLZ

4 REPLIES 4
az38
Community Champion
Community Champion

Hi @powpowpow 

your mention about different tables and slicer makes this task harder without data model, but as simple option you could use a measure

Dream result measure = 
DIVIDE(
CALCULATE(SUM('Table'[Availability]), ALLEXCEPT('Table', 'Table'[ITEM ID], 'Table'[RETAILER]) ),
CALCULATE(COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[ITEM ID], 'Table'[RETAILER]) )
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hello, 


Thanks so much for considering this post. 

 

Unfortunately Availability is a measure so I cannot sum it this way in DAX

 

The table I provided is fictional so I cant apply 'all except' on it. Provided the closest approximation to the data model I could in the above reply to Martyn. 

 

Please let me know if you need anything else

 

Thanks!!!!!!!!!!!!

MartynRamsden
Solution Sage
Solution Sage

Hi @powpowpow 

 

This sounds doable but in order to help you, we need to understand your data model a little better.

Are you able to share you pbix? If not, could you post some sample data but displayed in separate tables just like it exists in your model?

 

Best regards,
Martyn


If I answered your question, please help others by accepting it as a solution.

Hi Martyn, 

 

Thanks a lot for your response, really appreciate it.

 

I am unfortunately not able to share my pbix for confidentiality reasons but here is how the data model looks like.

ITEM Table

ITEM IDSTOCKPRICE
0151100,00012.5
0121225,00022.3
01338,00019.55

 

ITEM Detail Table

ITEM IDCategoryPRICE
0151Big12.5
0121Small22.3
0133Small19.55

 

Retailer Table:

RETAILERDOOR#DOOR#
BCBBCB#001BCB#001
BCBBCB#002BCB#002
APEAPE#003APE#003

 

The tables are all related one way or another and the data warehouse is a cube connected live to the BI

 

PS. Availability is a measure i created that is 1 if there is stock and 0 otherwise (so i cant sum it in DAX)

 

Hope this helps, 

 

Thanks so so much

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors