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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dannytan1112
Helper I
Helper I

100% stacked column with line

Hi,

 

I have already other cases, still got a problem here.

 

How to make a stacked 100% with line where 100% based on the sales per day(legend:Sales A,B, and C) and line PR_ratio per day with the value on the right y-axis?

 

Thanks a lot

Let's say I have 5 columns

 

DateSalesASalesBSales CPR_ratio
15/12/202210008006000.8
16/12/20228005502300.4
17/12/20223005007001.3
18/12/20226003004001.6
19/12/20225002005001.1
1 ACCEPTED SOLUTION
TomasAndersson
Solution Sage
Solution Sage

Ok, so you have two main issues:
1. To use a legend, you would want the sales data to be in the same column, with a new, separate column describing what attribute (A, B, C) the sales value refer to.
2. Power BI do not have a stacked 100% column chart with a line (for some reason), only a "regular" stacked bar chart. You need to create a measure to compensate for that.

1.
Can be solved in different ways. Depending on your source data (e.g. Excel) you can fix it there. But you can also use Power Query. If you go to your model, "Edit query" on the table and then under "Transform" choose "Unpivot columns" while having your three columns selected you get a result as below - with one column for all sales values and one column for all attributes. You might want to modify column names before doing the transform. 

This form makes it easier to work with.

TomasAndersson_0-1671093697231.png


2.
First, create a measure that modifies the sales value to the percentage of total sales for each day:

Sales % of total = 
DIVIDE(
    sum('Table'[Value]),            //Sum of sales (in current context, i.e. per date and attribute in this case)
    CALCULATE(sum('Table'[Value]),
    ALLSELECTED('Table'[Attribute])  //Total sales - sum of sales on this date for all attributes 
    )
)

 

Then you can use the Line and stacked column chart visual to create your 100% column chart with a line: 

TomasAndersson_1-1671094218047.png



Hope this helps!

 

View solution in original post

2 REPLIES 2
TomasAndersson
Solution Sage
Solution Sage

Ok, so you have two main issues:
1. To use a legend, you would want the sales data to be in the same column, with a new, separate column describing what attribute (A, B, C) the sales value refer to.
2. Power BI do not have a stacked 100% column chart with a line (for some reason), only a "regular" stacked bar chart. You need to create a measure to compensate for that.

1.
Can be solved in different ways. Depending on your source data (e.g. Excel) you can fix it there. But you can also use Power Query. If you go to your model, "Edit query" on the table and then under "Transform" choose "Unpivot columns" while having your three columns selected you get a result as below - with one column for all sales values and one column for all attributes. You might want to modify column names before doing the transform. 

This form makes it easier to work with.

TomasAndersson_0-1671093697231.png


2.
First, create a measure that modifies the sales value to the percentage of total sales for each day:

Sales % of total = 
DIVIDE(
    sum('Table'[Value]),            //Sum of sales (in current context, i.e. per date and attribute in this case)
    CALCULATE(sum('Table'[Value]),
    ALLSELECTED('Table'[Attribute])  //Total sales - sum of sales on this date for all attributes 
    )
)

 

Then you can use the Line and stacked column chart visual to create your 100% column chart with a line: 

TomasAndersson_1-1671094218047.png



Hope this helps!

 

Thanks a lot Tomas,

 

Let me try it. Really appreciate it. Thanks

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.