Forum Discussion
Calculated column creating duplicates under all categories
I am trying to put a count of projects by Billable RAG Status (Green,Amber,Red) in a column chart but the way my data is structured, the calculated column formula I have is showing a single ID under all RAG status categories instead of just under one.
The formula for the calculated column is: (yes I am referencing measures in this as well as the values do not exist in the original data source)
6 Replies
- ajohnso2
Solution Supplier
Please provide a sample pbix and your expected outcome
- Angith_Nair
Continued Contributor
Hi PaulinaJ
Replace your BillableRAGStatus calculated column with a measure that evaluates the RAG status for each project.
BillableRAGStatus = SWITCH( TRUE(), [BillableActual%] > 1, "Red", [EAC%Billable] <= 1, "Green", [BillableActual%] < 1 || [EAC%Billable] >= 1, "Amber", "No Status" )Create another measure to count the number of projects for each RAG status.
CountProjectsByRAG = COUNTROWS( FILTER( YourTable, [BillableRAGStatus] = "Red" ) ) + COUNTROWS( FILTER( YourTable, [BillableRAGStatus] = "Amber" ) ) + COUNTROWS( FILTER( YourTable, [BillableRAGStatus] = "Green" ) )Add BillableRAGStatus as the category for your column chart, and use CountProjectsByRAG as the value. This will count and categorize projects correctly based on the dynamically calculated RAG status.
- PaulinaJNew Member
How can I change the second measure to look at distinct count of rows? My raw data could have 300 rows for the same ID but I just want it to look at distinct row.
CountProjectsByRAG = COUNTROWS( FILTER( YourTable, [BillableRAGStatus] = "Red" ) ) + COUNTROWS( FILTER( YourTable, [BillableRAGStatus] = "Amber" ) ) + COUNTROWS( FILTER( YourTable, [BillableRAGStatus] = "Green" ) )Also, I am not able to add BillableRAGStatus as the category of the column chart, it is only allowing me to add it to tooltips
- Angith_Nair
Continued Contributor
Use the logic for BillableRAGStatus in a calculated column and then you can add this column into the axis of the column chart.
Also for CountProjectsByRAG, use DISTINCTCOUNT instead of COUNTROWS.
- AnonymousNot applicable
Hi PaulinaJ ,
Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!
Best Regards
Yilong Zhou