web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / CountIF when the corre...
Power Apps
Answered

CountIF when the correct answer was selected.

(0) ShareShare
ReportReport
Posted on by 16

Hello, Folks.

 

I'm trying to count if the correct radio button was selected, but I'm having some problems with that.

I have a table, intertwined with my app. The Column "Correta" has the right answer settled as "CE"

KelvinRicardo45_0-1699365484057.png

But my code does not count as the right answer

 

Set(Value1,CountIf(Table1, LookUp(Filter(Table1,ID=Text(perg)),CORRETA="CE").OPCOES=Radio1.SelectedText.Value));
Set(perg,perg+1);

Could you please help me with that ?

 

Categories:
I have the same question (0)
  • Hassan_SZ_365 Profile Picture
    542 on at

    Hi,

    To correct the code for counting if the selected radio button matches the correct answer in the "Correta" column, try this:

    1. Make sure that your LookUp function is returning the correct row for the question you're evaluating.
    2. Ensure that OPCOES_Radio1.SelectedText.Value matches the text exactly as it appears in the "Correta" column, including capitalization.
    3. Use CountIf to count the occurrences where the condition is met.

    Here's a simplified example of how your code might look:

     

     

    Set(Value1, CountIf(Table1, Correta = OPCOES_Radio1.SelectedText.Value));
    Set(perg, perg + 1);

     

     

    Make sure you replace Table1, Correta, and OPCOES_Radio1 with the actual names of your table, correct answer column, and radio button control if they are different. If there's still an issue, you may need to check for any additional conditions or context-specific configurations in your app.


    Best Regards,
    Hassan Raza

  • MudassarSZ365 Profile Picture
    591 on at

    Hi @KelvinRicardo45 

    try this 

    Set(Value1, CountIf(Table1, ID = perg && CORRETA = "CE" && OPCOES = Radio1.SelectedText.Value));
    Set(perg, perg + 1);
  • KelvinRicardo45 Profile Picture
    16 on at

    KelvinRicardo45_0-1699366719111.png

    Thanks for the answer. 

    I've tried this but it still not counting... 

     

  • KelvinRicardo45 Profile Picture
    16 on at

    Thanks a lot for the answer. 

    The Columns from the Table are matching with my labels on the PowerAps. I don't know what's happening right now.

    I've also tried to use "IF" to link the requirements, but it also didn't work so well.   

  • Verified answer
    MudassarSZ365 Profile Picture
    591 on at

    @KelvinRicardo45 

     

    Set(Value1, CountIf(Table1, ID = Text(perg) && CORRETA = "CE" && OPCOES = Radio1.SelectedText.Value));
    Set(perg, perg + 1);

     

    1. Data types mismatch: Ensure that the data type of the ID column in Table1 matches the data type of perg. If ID is a number, you don't need to convert perg to text; instead, you can directly compare them.

    2. Column Names: Make sure the column names used in the formula match exactly with the ones in your table. Power Apps is case-sensitive regarding column names.

    3. Selected Radio Button: Check if Radio1.SelectedText.Value is returning the value you expect. If the Radio1 control does not have a selection, .SelectedText.Value would be empty, and the condition would not be met.

    4. Delegation: If Table1 is large, this might be a delegation issue. Power Apps might not be able to process all rows on the server side, resulting in incomplete data. To confirm if this is the case, check for any delegation warning icons next to your formula.

    5. Correct usage of CountIf: CountIf should return the number of rows that meet all the criteria. If no rows meet the criteria, it will return 0.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard