cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hunainsami1
Helper I
Helper I

Merge filtered gallery rows on the basis of greater date

I have got into this problem and trying to solve this for hours but did not get any success.
Please see the screenshot attached below.
Screenshot_2.png

 

I am filtering the data in a gallery, based on different if conditions, There are 7 tabs above the gallery here in the screenshot.
When filtering the data for some if condition lets say in this case "Recent Hire" in I am getting multiple records for one personnel number. In this case for Personnel ID "003168" I am getting 4 records. I have sorted these records in descending order on the basis of date. What I want to get is the first row out of these 4 rows with the largest date. I want to get only one first row with largest date for each multiple records. So when any personnel number have multiple records I get only this first row with largest date after sorting. We have Personnel ID and Name as identical column here.

waiting for your generous response here.
Here is the code snippet for one condition. In this case "Recent Hire"
If(_FilterDateVar = true && _RecentHireVar = true,
Filter('[dbo].[TV_IAMintegration_VW]',EmpStartCalc >= _MonthStartCalculated And EmpStartCalc <= _MonthEndCalculated And EmpStartCalc <= _TodayCalculated And ((_MonthEndCalculated > PositionHierValidFromCalc And _MonthStartCalculated < PositionHierValidToCalc) Or PositionHierValidToCalc = Value("")) And ((_MonthEndCalculated > PositionDetailsValidFromCalc And _MonthStartCalculated < PositionDetailsValidToCalc) Or PositionDetailsValidToCalc = Value("")) And ((_MonthEndCalculated > PWAValidFromCalc And _MonthStartCalculated < PWAValidToCalc) Or PWAValidToCalc = Value(""))
))
@powerapps @PowerApps6 @PowerApps5 PowerApps Nested Gallery Filtering

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@hunainsami1 

I didn't see and screenshots other than the first supplied - is that what you are referring to?  

What I was mostly getting tripped up on in your formula was what was a field in your view and what was a variable.

The whole formula can be reduced to a rather simple formula, but not knowing the fields and the variables, it was hard to provide anything that would be useful. 

As mentioned, based on your original screenshot and what you want, the group by function is going to be needed.  But having to go through and put this in that formula was daunting. 

I'm about to break for the day, so provide what you can to assist and I will try to give it some cycles over the weekend.

_____________________________________________________________________________________
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

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

View solution in original post

4 REPLIES 4
RandyHayes
Super User III
Super User III

@hunainsami1 

I looked over your issue from your earlier post.

Your formula is way too convoluted and really needs to be refactored.  Mostly because what you need to do is group your results.  As you have it now, you have multiple-multiple filter statements in your formula.  You really need to reduce it down to one that includes the logic you have in all of those If statements into the criteria.

 

I began doing that for you but was not able to determine what was what in your formula.  Knowing the fields of your TV_IAMintegration_VW would assist in that process.

 

_____________________________________________________________________________________
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

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

Thank you for your help,
If I get the required result against this filter only which I mentioned in this post then I will use separate galleries for each filter.
The case is, We are getting the employees whose employment start date is within a selected month. ( _MonthStartCalculated and _MonthEndCalculated are selected month starting and ending date). Now when we have multiple position changes ( Manager , Department, Position Assigned) with in this month then we get multiple values for this personnel number. In this scenario we only want to get the latest date of position change for this month so we will only one row.

I hope that I have described it well. I am really trapped into this . With this detail if you see the screenshot now, you will understand better. In the screenshot there are 3 dates, (20200108 , 20200115, 20201209) in the first row for personnelid 003168, I want to take this row only, skipping the 3 rows below.

RandyHayes
Super User III
Super User III

@hunainsami1 

I didn't see and screenshots other than the first supplied - is that what you are referring to?  

What I was mostly getting tripped up on in your formula was what was a field in your view and what was a variable.

The whole formula can be reduced to a rather simple formula, but not knowing the fields and the variables, it was hard to provide anything that would be useful. 

As mentioned, based on your original screenshot and what you want, the group by function is going to be needed.  But having to go through and put this in that formula was daunting. 

I'm about to break for the day, so provide what you can to assist and I will try to give it some cycles over the weekend.

_____________________________________________________________________________________
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

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

View solution in original post

hunainsami1
Helper I
Helper I

Thank you for your response.

I have resolved this issue by separating the gallery for each if condition then use Add Column and Group by and Max function to get Max value for one personnel number. By doing this my powerapp was taking too much time to load.
So I shift the code to SQL level and get response back to powerapps using flow.
So this works like a charm and performance is also good now.

Thanks all
Tag me if anyone in future came across same issue.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (800)