Forum Discussion

PaulinaJ's avatar
PaulinaJ
New Member
1 year ago

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)

BillableRAGStatus = IF(CALCULATE([BillableActual%]>1),"Red",IF(CALCULATE([EAC%Billable]<=1),"Green",IF(CALCULATE([BillableActual%]<1 || [EAC%Billable]>=1),"Amber")))
 
I've attached screenshots as well. PS I cannot change the structure of my data and I need to use a calculated column as a measure does not allow me to have the column chart as clickable.

6 Replies

  • ajohnso2's avatar
    ajohnso2
    Icon for Solution Supplier rankSolution Supplier

    Please provide a sample pbix and your expected outcome

  • Hi PaulinaJ ,

    To diagnose the issue, you may create two calculated column of two different measures first to check what value you are getting. Then create the third column to flag it. Hope this will help. Please share sample data for better solution.

  • Angith_Nair's avatar
    Angith_Nair
    Icon for Continued Contributor rankContinued 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.

     

    • PaulinaJ's avatar
      PaulinaJ
      New 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's avatar
        Angith_Nair
        Icon for Continued Contributor rankContinued 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.

  • Anonymous's avatar
    Anonymous
    Not 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