cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dataguy33
Frequent Visitor

Define label value based on status of records child table data.

I have a Milestones table (parent) and an Activities table (child) where the milestones are comprised of a list of activities. I want to be able to define the overall milestone's status based on the statuses of the activities that relate to the milestone.

 

If the status of all the activities are "Not started" then the milestone is "Not started",

if a single activity is "in progress" then the milestone is "in progress",

if all activities are completed then the milestone is "completed",

if ANY of the activities are "delayed" then the milestone is "delayed".

 

Kind of new to PowerApps so I am not really sure where to start. 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@dataguy33 

For your label Text property, set the following formula:

With({_items: yourGallery.AllItems},
    With({_count: CountRows(_items)},
        If(_count=CountRows(Filter(_items, status="Not started")), "Not started",
           _count=CountRows(Filter(_items, status="completed")), "completed",
           CountRows(Filter(_items, status="delayed"))>0, "delayed",
           CountRows(Filter(_items, status="in progress"))>0, "in progress"
        )
    )
)

I only use the With's to avoid the repetitive typing.

 

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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

4 REPLIES 4
RandyHayes
Super User III
Super User III

@dataguy33 

For your label Text property, set the following formula:

With({_items: yourGallery.AllItems},
    With({_count: CountRows(_items)},
        If(_count=CountRows(Filter(_items, status="Not started")), "Not started",
           _count=CountRows(Filter(_items, status="completed")), "completed",
           CountRows(Filter(_items, status="delayed"))>0, "delayed",
           CountRows(Filter(_items, status="in progress"))>0, "in progress"
        )
    )
)

I only use the With's to avoid the repetitive typing.

 

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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

This worked! However, it is failing with a record that has one activity with "completed" and one with "not started". 

I just used another else "In Progress" and that seemed to do the trick. So if the condition is not met in the formula, it just evaluates as "in progress". Really appreciate it!

RandyHayes
Super User III
Super User III

@dataguy33 

Yes, that would be a slightly different condition that wasn't really mentioned at first.  But sounds like you got it in and working properly!! 😁

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (43,214)