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
singarfield
Helper I
Helper I

Bar chart split by age and total

Hi everyone, 

At the moment I have this bar chart, but I would like to create an additional column where I get all the responses in a stacked bar, aggregated by age. How would I go about doing this?

age query.png

Thank you

Sara

2 ACCEPTED SOLUTIONS
v-yuezhe-msft
Employee
Employee

@singarfield,

You can create a measure using similar DAX as below. Then use Line and stacked column chart to dispaly the data, or drag the measure to tooltips of your current bar chart.

Measure = CALCULATE([yourmeasure],ALLEXCEPT(Table,Table[Age]))

1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

@singarfield,

Right-click your table, and select "New Measure", then apply above formula.
1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

5 REPLIES 5
v-yuezhe-msft
Employee
Employee

@singarfield,

You can create a measure using similar DAX as below. Then use Line and stacked column chart to dispaly the data, or drag the measure to tooltips of your current bar chart.

Measure = CALCULATE([yourmeasure],ALLEXCEPT(Table,Table[Age]))

1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, 

Im still very new to power BI, so this doesn't really tell me where I would go to create this value. Could you give more of a step-by-step answer, please?

Thank you

Sara

@singarfield,

Right-click your table, and select "New Measure", then apply above formula.
1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you!

Sara

AkhilAshok
Solution Sage
Solution Sage

I don't think you have an option to add Grand Total in a bar chart. A workaround would be the following:

 

1. Create a new dimension table Age:

Age New = 
UNION (ROW("Age", "Total"), VALUES(Table[Age]))

2. Create a relationship between the Age column in this new dimension table and your fact table.

 

3. Create a new measure:

Measure New =
SWITCH (
    SELECTEDVALUE ( 'Age New'[Age] ),
    "Total", CALCULATE ( [Measure], ALL ('Age New'[Age]) ),
    [Measure]
)

4. Use this Measure New and Age New dimension in your chart.

 

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.