Forum Discussion
Line chart line and legend
Hello
I would like to draw a bar graph with a legend from different groups. With the hierarchy of data and the sum total.
This three graph in one.
thenks
Lp
LEa
2 Replies
- Greg_DecklerCommunity Champion
Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
- v-gizhi-msftCommunity Support
Hi,
According to your description, I create a table to test:
Please take following steps:
1)Create a calculated table:
Table = UNION(ADDCOLUMNS(DISTINCT('Test'[Location]),"Level","Location"),ADDCOLUMNS(DISTINCT('Test'[OrderID]),"Level","OrderID"),ADDCOLUMNS(DISTINCT('Test'[Product]),"Level","Product"))
And it shows:
2)Create a measure to calculate the [Amout] by three levels:
Measure =
CALCULATE (
SUM ( Test[Amout] ),
FILTER (
Test,
SWITCH (
SELECTEDVALUE ( 'Table'[Level] ),
"Product", 'Test'[Product] = SELECTEDVALUE ( 'Table'[Element] ),
"Location", 'Test'[Location] = SELECTEDVALUE ( 'Table'[Element] ),
"OrderID", 'Test'[OrderID] = SELECTEDVALUE ( 'Table'[Element] )
)
)
)
3)The result shows:
You can also use ‘Table’[Level] as a slicer to filter the above visual:
Here is my test pbix file:
Best Regards,
Giotto Zhi