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
javedbh
Helper II
Helper II

Drilldown and Groupby - individual total divided by group total

Here is the data I have

 

MainCategory |
SubCategory |
Device |
Lot |
SubLot |
Bin |
PartCount
Cat1SubCat1Dev1Lot1Sub0309
Cat1SubCat1Dev1Lot1Sub03118
Cat1SubCat1Dev1Lot1Sub03215
Cat1SubCat1Dev1Lot1Sub04511
Cat1SubCat1Dev1Lot1Sub1307
Cat1SubCat1Dev1Lot1Sub1314
Cat1SubCat1Dev1Lot1Sub13223
Cat1SubCat1Dev1Lot1Sub15016
Cat1SubCat1Dev1Lot1Sub1528
Cat1SubCat1Dev1Lot2Sub03015
Cat1SubCat1Dev1Lot2Sub03117
Cat1SubCat1Dev1Lot2Sub03211
Cat1SubCat1Dev1Lot2Sub04518
Cat1SubCat1Dev1Lot2Sub1309
Cat1SubCat1Dev1Lot2Sub1315
Cat1SubCat1Dev1Lot2Sub13217
Cat1SubCat1Dev1Lot2Sub15011
Cat1SubCat1Dev1Lot2Sub1523
Cat1SubCat1Dev2Lot3Sub0309
Cat1SubCat1Dev2Lot3Sub03118
Cat1SubCat1Dev2Lot3Sub03215
Cat1SubCat1Dev2Lot3Sub1307
Cat1SubCat1Dev2Lot3Sub1314
Cat1SubCat1Dev2Lot3Sub13223
Cat1SubCat1Dev2Lot4Sub03015
Cat1SubCat1Dev2Lot4Sub03117
Cat1SubCat1Dev2Lot4Sub03211
Cat1SubCat1Dev2Lot4Sub04518
Cat1SubCat1Dev2Lot4Sub1309
Cat1SubCat1Dev2Lot4Sub1315
Cat1SubCat1Dev2Lot4Sub13217
Cat1SubCat1Dev2Lot4Sub15011

 

I want to create a bar chart with multiple drill down.

 

Following columns are added in the x-Axis for multiple drill down:

MainCategory, SubCategory, Device, Lot, SubLot

 

Column "Bin" is added under Legend.

 

Note: Drill Mode is on - select a data point to drill

Note: User is not interested in all bins, only some of the bins.

 

I want to display percentage of individual bin at whatever the level (drill down/group by) the user is at. Column "PartCount" will be used to get count of individual bin and also to get count of all bins at selected level.

 

E.g. user has drilled down like Cat1->SubCat1->Dev1->Lot1. Now Sub0 and Sub1 are displaying. User want to see percentage of bin 30, 45, 50. Total PartCount is 53 in Sub0 and 58 in Sub1. The data should be something like this:

 

Group by SubLot       
MainCategorySubCategoryDeviceLotSubLotBinPartCountTotal By SubLotPercentage
Cat1SubCat1Dev1Lot1Sub0309539/53*100=16.9811321
Cat1SubCat1Dev1Lot1Sub045115311/53*100=20.754717
Cat1SubCat1Dev1Lot1Sub1307587/58*100=12.0689655
Cat1SubCat1Dev1Lot1Sub150165816/58*100=27.5862069

 

If the user is at Lot level (Cat1->SubCat1->Dev1):

 

Total PartCount in Lot1 = 111

Total PartCount in Lot2 = 106

 

Group by Lot       
MainCategorySubCategoryDeviceLotBinPartCountTotal By LotPercentage
Cat1SubCat1Dev1Lot1301611114.41441441
Cat1SubCat1Dev1Lot145111119.90990991
Cat1SubCat1Dev1Lot1501611114.41441441
Cat1SubCat1Dev1Lot2302410622.64150943
Cat1SubCat1Dev1Lot2451810616.98113208
Cat1SubCat1Dev1Lot2501110610.37735849

 

Please tell me how I can achieve this measure!!!

 

Any help would be greatly appreciated.

2 ACCEPTED SOLUTIONS
Sean
Community Champion
Community Champion

@javedbh  Did you try the column and line chart?

 

Organize as in the picture...

GroupBy3.png

View solution in original post

@Sean The query you added in your reply solved the problem. Thanks.

 

Here is the result:

solution.png

View solution in original post

10 REPLIES 10
Sean
Community Champion
Community Champion

@javedbh Yes you can do this with a Line and Column chart.

 

But the % will show 100% up until you get to the final drill down level.

GroupBy.png

 

Why don't you use a Matix.

GroupBy2.png

@Sean Can you tell me how do you calculate "% of Lot" column?

 

Also is it possible to show %age like the following format:

sample.png

 

Thanks

ankitpatira
Community Champion
Community Champion

@javedbh I have played with your scenario for a while now. I created sample dataset as yours however it doesn't turn out to be easy to do in PBI as what you want is conditional totalling based on the level user navigates to.

 

What I would suggest is instead of having one bar chart create multiple bar charts for each level that way it would be easy enough to do just in power bi. Let me know if you want to take this approach and I can give you list of steps to follow.

 

Other option is to use R in power bi which is very powerful to do these  type of transformation but for that you need to know R. Again let me know if you wan't to take R approach.

@ankitpatira I did tried multiple charts option. I used one bar chart and one line chart. Bar chart is used for levels and line chart for bins and bin percentage. Selecting one datapoint in bar would display percentage of bins of the selected datapoint in the line chart. But it is not a perfect solution.

 

I would be interested in your proposed R solution. Can you help me with that?

 

Thanks

Sean
Community Champion
Community Champion

@javedbh  Did you try the column and line chart?

 

Organize as in the picture...

GroupBy3.png

@Sean The query you added in your reply solved the problem. Thanks.

 

Here is the result:

solution.png

@Sean I will definitely try this and thanks for puthing the formula for the % measure.

I want something like one of the following (created in excel):

sample1.png

 

sample2.png

 

Sean
Community Champion
Community Champion

@javedbh this is not possible in PBI but there's an idea here if you want to Vote for Nested X-Axis (I've already voted for it)

 

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/11524623-nested-x-axis-labels

 

@Sean Nested X Axis are definitely good but for the time being I'm not interested in them for the problem I posted. I just wanted to show that if there are e.g. multiple x-axis items (e.g. Lot1, Lot2, Lot3, Lot4 on x-axis) then each item should have multiple bars (one for each bin).

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.