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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Aimeeclaird
Helper IV
Helper IV

Dax Measure: Count occurrence of text and If statement

Hi, looking for some help please.

 

I have data from an MS forms assessment we have created. The user will complete the assessment and a RAG status will be assigned based on their response. 

 

I need to write a measure that calculates an overall RAG status for the Executive Summary page of the report. 

 

Exmaple of data: PBI Community Example Data.xlsx

 

How can I calculate based on the logic included in the file what the overal RAG status for the section of questions is?

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Aimeeclaird , Try a new column like

 

new column =
var _all= countx(filter(table,[Question section] =earlier([Question section])),[Question section])
var _red = countx(filter(table,[Question section] =earlier([Question section]) && [Response] ="Red" ),[Question section])
var _amber = countx(filter(table,[Question section] =earlier([Question section]) && [Response] ="Amber" ),[Question section])
var _green = countx(filter(table,[Question section] =earlier([Question section]) && [Response] ="Green" ),[Question section])
return
switch( true() ,
_red >=2, "RED"
_amber >=2 , "AMBER "
_green = _all , "GREEN",
_green >=1 && _amber=1 , "GREEN",
"Other"
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@Aimeeclaird 

Your logic is not clear, can you explain with the help of your sample data:

Fowmy_0-1626694129603.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy thanks for the reply. I've tried to explain my logic better in the file. Let me know if this helps. Also open to other suggestions of better logic to apply if you have anything!

amitchandak
Super User
Super User

@Aimeeclaird , Try a new column like

 

new column =
var _all= countx(filter(table,[Question section] =earlier([Question section])),[Question section])
var _red = countx(filter(table,[Question section] =earlier([Question section]) && [Response] ="Red" ),[Question section])
var _amber = countx(filter(table,[Question section] =earlier([Question section]) && [Response] ="Amber" ),[Question section])
var _green = countx(filter(table,[Question section] =earlier([Question section]) && [Response] ="Green" ),[Question section])
return
switch( true() ,
_red >=2, "RED"
_amber >=2 , "AMBER "
_green = _all , "GREEN",
_green >=1 && _amber=1 , "GREEN",
"Other"
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak thanks for the reply.

 

I've used the above to create a new column but unfortunately everything is calculted as 'other'. Not sure if (as the comment above mentions) the problem is with the logic I am trying to use?

Hi @amitchandak Sorry, ignore that! I had made a mistake. I've resolved now but have identified a couple of scenarios not covered by my logic. I will adjust this using your suggested formula. Thanks for the help!

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors