The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi, I would like to create a horizontal stacked bar chart with each bar showing count of values from a seperate column. Seeking advice on how to go about this and what is the appropropriate dax measure.
Thanks in advance
Create a New Table:
NewTable = UNION(VALUES(Table[Column1]), VALUES(Table[Column2]), VALUES(Table[Column3]))
Replace Table with your actual table name, and Column1, Column2, Column3 with your actual column names.
Count Rows in the New Table:
CountRowsMeasure = COUNTROWS(NewTable)
Create a Stacked Bar Chart:
This way, each bar in your chart will represent the count of values from a separate column.
Here's an example of what the DAX might look like:
NewTable = UNION(VALUES(Table[Column1]), VALUES(Table[Column2]), VALUES(Table[Column3]))
CountRowsMeasure = COUNTROWS(NewTable)
Adjust the DAX expressions based on your specific data model and requirements.
Remember, this is a generalized approach, and the exact steps might vary depending on your specific dataset and the tool you are using (Power BI, Excel, etc.). If you have more specific details about your data structure or the tool you are using, I can provide more targeted guidance.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Thankyou for providing this solution. I have completed your instructions however it is not returning the results in the visual for each Column, nor the correct count. Below is what I have applied and the results. Would appreciate any further advice on this.
Table
There should actually be a count of 57 for 'Readiness Assessment', 1 for 'Peer Review' and remainder 'Blank'.
It appears that the UNION function may not be the most suitable approach for your case, as it combines distinct values from different columns into a single column. Since you want to count the occurrences of specific values in each column separately, a different approach is needed.
You can use the following steps to achieve your goal:
Create a New Table: Instead of using UNION, create a new table that contains the values from each column separately.
Actions Table =
UNION(
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[SRImprovementAction]),
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[SLImprovementAction]),
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[PEImprovementAction]),
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[IR1ImprovementAction]),
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[IR2ImprovementAction]),
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[IR3ImprovementAction]),
SELECTCOLUMNS('E&T Documented Information Review Tracker', "Action", 'E&T Documented Information Review Tracker'[IR4ImprovementAction])
)
This way, you have a table with a column named "Action" that contains values from each of your original columns.
Create Count Measures: Create separate count measures for each action.
CountSRImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "SRImprovementAction"))
CountSLImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "SLImprovementAction"))
CountPEImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "PEImprovementAction"))
CountIR1ImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "IR1ImprovementAction"))
CountIR2ImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "IR2ImprovementAction"))
CountIR3ImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "IR3ImprovementAction"))
CountIR4ImprovementAction = COUNTROWS(FILTER('Actions Table', 'Actions Table'[Action] = "IR4ImprovementAction"))
Adjust these measures according to your actual action names.
Create Stacked Bar Chart: Use these measures in a horizontal stacked bar chart.
Now, your visual should display the counts of each action separately. If there are still issues, please double-check the action names and the data in your columns to ensure they match.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
18 | |
18 | |
17 | |
15 | |
11 |
User | Count |
---|---|
35 | |
34 | |
19 | |
19 | |
14 |