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
unkuser
Regular Visitor

Need Help: How to group by multiple conditions and calculate aggregated contribution

Hi,

 

I'm here seeking for the wisdom of PowerBI masters.

I would like to plot a chart in PowerBI that could give the % contribution for a multiple conditional grouping.

To illustrate the issue, please find the table below:

 

ComponentProjectTypeArea Used by ComponentTotal Area available for ProjectSubmiter
XA1NORMAL1030FAB
YB1EXTRA1240IT
ZC1NORMAL1130IT
KD1EXTRA1540FAB
MA1NORMAL1730IT
NB1EXTRA1040FAB
OC1NORMAL1230FAB
PD1EXTRA1340IT

 

Based on a table like this, I would like to have the agreggated % contribution per Project Type and Submitter.

For the above example, if doing the calculations manually, we would have:

 

 NORMALEXTRA
FAB22/6025/80
IT28/6025/80
UNUSED AREA10/6030/80

 

The resulting chart should be like below:

unkuser_0-1620409107827.png

 

However, I could not find a way in Power BI to dynamically perform this operation...

 

Any help or suggestion is very welcome.

 

Thanks!

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @unkuser 

According to your description, I can roughly understand your requirement, I think your requirement can be separated into two parts, one part is the table and another is the column chart because the columns in the output table can’t be placed as the axis and value of the column chart, you can try my steps:

  1. Create a calculated table:
Output =

SUMMARIZE('Table',[Submiter])
  1. Create two calculated columns in the table like this:
NORMAL =

var _total=SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Normal"),[Total Area available for Project])

var _area= SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Normal"),[Area Used by Component])

return

DIVIDE(_area,_total)
EXTRA =

var _total=SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Extra"),[Total Area available for Project])

var _area= SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Extra"),[Area Used by Component])

return

DIVIDE(_area,_total)

This is the output:

v-robertq-msft_0-1620699487595.png

 

  1. To get the 100% stacked column chart, you should create a measure in the main table first:
Value =

DIVIDE(

    SUM('Table'[Area Used by Component]),

SUM('Table'[Total Area available for Project]))
  1. Then create a 100% stacked column chart and place it like this:

v-robertq-msft_1-1620699487602.png

 

Then change the data color, and you can get what you want.

You can download my test pbix file below

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-robertq-msft
Community Support
Community Support

Hi, @unkuser 

According to your description, I can roughly understand your requirement, I think your requirement can be separated into two parts, one part is the table and another is the column chart because the columns in the output table can’t be placed as the axis and value of the column chart, you can try my steps:

  1. Create a calculated table:
Output =

SUMMARIZE('Table',[Submiter])
  1. Create two calculated columns in the table like this:
NORMAL =

var _total=SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Normal"),[Total Area available for Project])

var _area= SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Normal"),[Area Used by Component])

return

DIVIDE(_area,_total)
EXTRA =

var _total=SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Extra"),[Total Area available for Project])

var _area= SUMX(FILTER(ALL('Table'),[Submiter]=EARLIER([Submiter])&&[Type]="Extra"),[Area Used by Component])

return

DIVIDE(_area,_total)

This is the output:

v-robertq-msft_0-1620699487595.png

 

  1. To get the 100% stacked column chart, you should create a measure in the main table first:
Value =

DIVIDE(

    SUM('Table'[Area Used by Component]),

SUM('Table'[Total Area available for Project]))
  1. Then create a 100% stacked column chart and place it like this:

v-robertq-msft_1-1620699487602.png

 

Then change the data color, and you can get what you want.

You can download my test pbix file below

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Will there only be 2 submitter types - FAB and IT?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

 

No. Number of submitters can grow up over time.

 

Thank you,

 

 

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
davehus
Memorable Member
Memorable Member

Hi, Create measures as follows

FAB = CALCULATE(SUM(Matrix[Area Used by Component]), KEEPFILTERS(Matrix[Submiter]="FAB"))
IT = CALCULATE(SUM(Matrix[Area Used by Component]), KEEPFILTERS(Matrix[Submiter]="IT"))

 

Create a calculated column in your report as below:

 

Total By Type = Var MaxValues = CALCULATE(SUM([Total Area available for Project]), ALLEXCEPT(Matrix,Matrix[Type],Matrix[Submiter])) Return MaxValues
 
Create Measure
Unused Area = Var MaxV = MAX(Matrix[Total By Type]) RETURN MaxV-([FAB]+[IT])
 
Then build your chart as below:
 
davehus_0-1620425542240.png

 

 Hope this helps

Hi davehus,

 

Thanks for the hints. It works fine for the types, but not for the Unused Area.

If we try to filter the chart by Project, the Unused Area will not be automatically updated to reflect the filters...

Any ideas ?

 

Thanks

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.