Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
vineetthakur
New Member

add calculate column on power bi matrix with text value

Hi Professionals,

 

I have the following data source file with usage rag rating of each product (or the products bought by each customer): 

 

CustomerProductRAG Rating
id1ARed
id2BAmber
id1BGreen
id4CGreen
id3CRed
id1CAmber
id3BRed

 

i have been able to create a power bi matrix visual below : 

 

CustomerABC
id1RedGreen 
id2 Amber 
id3 RedRed
id4  Green

 

Now, i need to create a calculated column (Overall RAG) in the power bi matrix visual like below. The logic for this is that if there is a red (for at least one product )then overall rag is red, amber (if no red and at least one amber) and green (if all are green), Please can you help with any suggestions? Thank you!

 

CustomerABCOverall RAG
id1RedGreen Red
id2 Amber Amber
id3 RedRedRed
id4  GreenGreen
1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@vineetthakur , Create a new calculated column by going to Modelling tab

 

DAX
Overall RAG =
VAR CustomerID = 'YourTableName'[Customer]
VAR RedCount = CALCULATE(COUNTROWS('YourTableName'), 'YourTableName'[Customer] = CustomerID, 'YourTableName'[RAG Rating] = "Red")
VAR AmberCount = CALCULATE(COUNTROWS('YourTableName'), 'YourTableName'[Customer] = CustomerID, 'YourTableName'[RAG Rating] = "Amber")
VAR GreenCount = CALCULATE(COUNTROWS('YourTableName'), 'YourTableName'[Customer] = CustomerID, 'YourTableName'[RAG Rating] = "Green")
RETURN
IF(RedCount > 0, "Red",
IF(AmberCount > 0, "Amber",
IF(GreenCount > 0, "Green", BLANK())
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

1 REPLY 1
bhanu_gautam
Super User
Super User

@vineetthakur , Create a new calculated column by going to Modelling tab

 

DAX
Overall RAG =
VAR CustomerID = 'YourTableName'[Customer]
VAR RedCount = CALCULATE(COUNTROWS('YourTableName'), 'YourTableName'[Customer] = CustomerID, 'YourTableName'[RAG Rating] = "Red")
VAR AmberCount = CALCULATE(COUNTROWS('YourTableName'), 'YourTableName'[Customer] = CustomerID, 'YourTableName'[RAG Rating] = "Amber")
VAR GreenCount = CALCULATE(COUNTROWS('YourTableName'), 'YourTableName'[Customer] = CustomerID, 'YourTableName'[RAG Rating] = "Green")
RETURN
IF(RedCount > 0, "Red",
IF(AmberCount > 0, "Amber",
IF(GreenCount > 0, "Green", BLANK())
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.