cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
techtudoor
Resolver I
Resolver I

CountRows to display in Radio Control with multiple criteria

Hello PowerApps Guru's. I am stuck on configuring a dynamic radio control. I have a data source (SharePoint List) named "Data1", that has 6 fields. On my Screen I am filtering a gallery with two (2) Radio controls. The first Radio control (Radio1) is pulling from a Choice column named "Type" from "Data1" data source. What I would like to do is have the second Radio control show all the used choices from "Status" field in "Data1" data source. I would also like to show the count of how many "Type's" have of each Statuses ("Status" field). I have included a demo of my data source setup.

 

Data Source: This shows inventory of items to be checked out

"Data1"

Columns :

"Type" - Choice column, choices are  "widget", "thingamabob", "doo-hickey"

"Status" - Choice column, choices are "Available", "Checked Out", "Disposed"

 

So if I have 3 "widgets" Available, 2 "widgets" Checked Out and 5 "widgets" Disposed. I would like to have the radio buttons look similar to: (underline denotes selected value)

 

Radio1 - Widgets    Thingamabob    doo-hickey

Radio2 - Available (3)    Checked Out (2)    Disposed (5)

 

I am using the following syntax for Radio2:

 

AddColumns(
    GroupBy(
        ShowColumns(
            AddColumns(
                Data1,
                "State",
                Status.Value,
                "Item",
                Type.Value
            ),
            "State"
        ),
        "State",
        "Data"
    ),
    "Status Count",
    State & " (" & CountRows(Data) & ")"
)

 

I just need to do a comparison of "Type" from the data source to the selected value of Radio1.

 

Any suggestions are greatly appreciated. 

 

On a side note, I can get this to work if I do an If statement using CountRows(Filter( for each possible outcome, but would prefer to use this way as it would update dynamically.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@techtudoor 

Yes, slightly misunderstood your request.  

You can avoid all the show columns functions, they aren't really going to bring you any value in this.

You will want to get down to one hit at the data rather than doing it over and over in the second radio control.

 

Set the Radio1 Items property to:

AddColumns(
    AddColumns(
        Distinct(Data1, Type.Value),   
        "_stats", AddColumns(Filter(Data1, Type.Value = Result), "_stat", Status.Value)
    ),
    "_statusCounts", AddColumns(GroupBy(_stats, "_stat", "_data"), "_Counts", _stat & " (" & CountRows(_data) & ")")
)

 

Set the Radio2 Items property to:

   Radio1.Selected._statusCounts

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@techtudoor 

Change the Items property of your Radio1 to:

AddColumns(
    GroupBy(
        AddColumns(Data1,
            "_type", Type.Value,
            "_status", Status.Value
        ),        
        "_type", "_status",
        "_records"
    ),
    "StatusCount", _status & " (" & CountRows(_records) & ")"
)

 

Set the Items property of Radio 2 to:  Radio1.Selected_data

 

This should give you what you are looking for.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you @RandyHayes , this shows the count for Radio1. I need the count to be in Radio2. So Radio1 shows "widgets" and Radio2 will show Available (3)    Checked Out (2)    Disposed (5).

 

I am trying to work on your suggestion and I am getting the correct Items listed, but not showing any count values in Radio2. 

 

I did need to modify Radio1 to:

 

ShowColumns(
    AddColumns(
        Data1,
        "Type",
        Type.Value,
        "State",
        Status.Value
    ),
    "Type"
)

 

Radio2 looks like:

 

AddColumns(
    GroupBy(
        ShowColumns(
            AddColumns(
                Data1,
                "State",
                Status.Value,
                "Type",
                Type.Value
            ),
            "State"
        ),
        "State",
        "Data"
    ),
    "Status Count",
    Radio1.Selected.Type & " (" & CountRows(Data) & ")"

 

This shows the correct Status values, but no counts...

RandyHayes
Super User
Super User

@techtudoor 

Yes, slightly misunderstood your request.  

You can avoid all the show columns functions, they aren't really going to bring you any value in this.

You will want to get down to one hit at the data rather than doing it over and over in the second radio control.

 

Set the Radio1 Items property to:

AddColumns(
    AddColumns(
        Distinct(Data1, Type.Value),   
        "_stats", AddColumns(Filter(Data1, Type.Value = Result), "_stat", Status.Value)
    ),
    "_statusCounts", AddColumns(GroupBy(_stats, "_stat", "_data"), "_Counts", _stat & " (" & CountRows(_data) & ")")
)

 

Set the Radio2 Items property to:

   Radio1.Selected._statusCounts

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you @RandyHayes , you are AMAZING!!! That worked GREAT!! 

 

Thank you so much!!

RandyHayes
Super User
Super User

@techtudoor 

Happy to help.  Sorry I misunderstood at first.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,302)