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
Olwin
Frequent Visitor

Bar Chart with combined dynamics legend

Hi there,

 

I want to make a bar chart like what I've done in Excel with the data structure like below:

 

 Jan-2021 Feb-2021 
 BudgetSalesBudgetSales
Branch "A"100090012001500
Branch "B"1500180016001400
Branch "C"2000220021001800

 

Olwin_0-1631787781327.png

 

Actually my data will come from 2 tables: Budget and Sales.

 

Sales Table:

Branch CodeDateSales Amount
Branch "A"1-Jan-2021900
Branch "B"1-Jan-20211800
Branch "C"1-Jan-20212200
Branch "A"1-Feb-20211500
Branch "B"1-Feb-20211400
Branch "C"1-Feb-20211800

 

Budget Table:

Branch CodeDateBudget Amount
Branch "A"1-Jan-20211000
Branch "B"1-Jan-20211500
Branch "C"1-Jan-20212000
Branch "A"1-Feb-20211200
Branch "B"1-Feb-20211600
Branch "C"1-Feb-20212100

 

Is there any possibilities to create a chart like my Excel Chart in Power BI?

 

Thanks.

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

Hi  @Olwin ,

Here are the steps you can follow:

1. Create calculated column.

Budget Table:
Column = [Date].[Date]&" "&"Budget"

vyangliumsft_0-1632125443450.png

Sales Table:
Column = [Date].[Date]&" "&"Sales"

vyangliumsft_1-1632125443453.png

2. Create calculated table.

Table =
UNION(
SELECTCOLUMNS('Sales Table',"Code",[Branch Code],"Column",[Column],"Amount",[Sales Amount]),
SELECTCOLUMNS('Budget Table',"Code",[Branch Code],"Column",[Column],"Amount",[Budget Amount]))

vyangliumsft_2-1632125443454.png

3. Place [Code] of Table to Axis, [Column] to Legend, and [Amount] to Values.

vyangliumsft_3-1632125443455.png

4. Result:

vyangliumsft_4-1632125443457.png

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Olwin ,

Here are the steps you can follow:

1. Create calculated column.

Budget Table:
Column = [Date].[Date]&" "&"Budget"

vyangliumsft_0-1632125443450.png

Sales Table:
Column = [Date].[Date]&" "&"Sales"

vyangliumsft_1-1632125443453.png

2. Create calculated table.

Table =
UNION(
SELECTCOLUMNS('Sales Table',"Code",[Branch Code],"Column",[Column],"Amount",[Sales Amount]),
SELECTCOLUMNS('Budget Table',"Code",[Branch Code],"Column",[Column],"Amount",[Budget Amount]))

vyangliumsft_2-1632125443454.png

3. Place [Code] of Table to Axis, [Column] to Legend, and [Amount] to Values.

vyangliumsft_3-1632125443455.png

4. Result:

vyangliumsft_4-1632125443457.png

 

Best Regards,

Liu Yang

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

Hi @v-yangliu-msft 

It worked as expected. Thank you for your support.

Olwin
Frequent Visitor

Hi @amitchandak, thanks for your guidance. I am now able to create 4 bars for each Branch like my Excel.

 

I still have question:

1. How can we make a measure name change dynamically? My expection would be:

    MTD Sales = February 2021 Sales

    last MTD Sales = January 2021 Sales

    MTD Budget = February 2021 Budget

    last MTD Budget = January 2021 Budget

 

so that we can find out the period of the data in that bar chart.

 

Olwin_0-1631800102893.png

 

Thank you.

amitchandak
Super User
Super User

@Olwin , You need common brach table and date table and create 4 measures 

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

MTD Budget= CALCULATE(SUM(Budget[BudgetAmount]),DATESMTD('Date'[Date]))
last MTD Budget= CALCULATE(SUM(Budget[BudgetAmount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

 

Common table

Bridge Table: https://www.youtube.com/watch?v=Bkf35Roman8&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=19

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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.