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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Syndicate_Admin
Administrator
Administrator

Variable value zero issue in powerapps

Hi,

 

I am creating a quiz in powerapps wherein for every score there is a comment viz if the total score is 10 it will be poor, for 20 it will be Okay, like wise.  The issue is that everything is working fine but for total score zero.  When all answers are wrong instead of it taking it as zero and comment being Very Poor it is showing blank.  The formula is as mentioned below.  Score is the variable:

 

Switch(Score,0,"poor",10,"bad",20,"Not Good",30,"Okay",40,"Good",50,"Excellent")

 

Kindly help in resolving this.

Regards

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Hi @Uday21 ,

Works perfectly fine for me as is - took your code, pasted it into text label.

Added a slider, set it to update Score var on change - 0 results in "poor" on text label - so in practice the logic is sound.

The only thing I can think of in your situation is that Score somehow has not yet been actually set when you get this result?

 

This can happen if Score is only set based on a function in the app, and it's never actually set by that function, then it will be Blank() until it is Set. 

For example, let's say you only Set the score when someone gets something right, but don't do anything when someone gets it's wrong - then you can end up in a situation where if someone got everything wrong, then Score will never be set.

If this is happening, then the best way to avoid it is to Set(Score, 0) before the quiz starts to make sure it has a value.

Kind regards,

RT

Syndicate_Admin
Administrator
Administrator

What is the score variable showing as its value when they are all wrong - likely its Blank rather than zero.

You could try changing the way you reference the score value, like this maybe:

 

If(
   IsBlank(Score), "poor",
   Score <10, "poor",
   Score <20, "bad",
   Score <30, "Not Good",
   Score <40, "Okay",
   Score <50, "Good",
   Score >=50, "Excellent"
)

 

lbendlin
Super User
Super User

Wrong forum.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors