cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FakeHungry
New Member

Add value from multiple rows which match criteria

I'm trying to add multiple tasks which match date and serial number. UI looks something like below.

Capture.PNG

First, you need to input start date, end date, and serial number. Then, it'll calculate date range between two date as on the right of the picture. Finally, I need to pull tasks and max ot with match criteria next to the date.

Capture.PNG

This is my sample data. If I search with criteria startDate=1/9/21, endDate=30/9/21, and S/N=FB/6, I will get tasks_ID=13,14,15 (within the same record) and OT=7.50.

 

Any suggestions are welcom.

 

Thanks,

FakeHungry

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Community Champion
Community Champion

Hi @FakeHungry 

 

ClearCollect(
    ColTasksH,
    GroupBy(
        Sort(
            Filter(
                [@TasksH],
                Request_Date >= StartDateH_1.SelectedDate && Request_Date <= EndDateH_1.SelectedDate && 'Vehicle_S/N' = SNSearch_1.Text
            ),
            OT,
            Descending
        ),
        "Request_Date",
        "RequestDateTable"
    )
);
ForAll(
    ColTasksH,
    Collect(
        ColTasksHNew,
        {
            Request_Date: ThisRecord.Request_Date,
            OT: First(ThisRecord.RequestDateTable).OT,
            Task_ID: Concat(ThisRecord.RequestDateTable,Task_ID,",")
        }
    )
)

StalinPonnusamy_0-1634478315495.png

Source

StalinPonnusamy_1-1634478405011.png

 

 

View solution in original post

3 REPLIES 3
StalinPonnusamy
Community Champion
Community Champion

Hi @FakeHungry 

 

Set the OnSelect property of the Search button to

ClearCollect(
    ColTasksH,
    Sort(
        Filter(
            TasksH,
            Request_Date >= StartDateH.SelectedDate && Request_Date <= EndDateH.SelectedDate && 'Vehicle_S/N' = SNSearch.Text
        ),
        OT,
        Descending
    )
)

 

 Set the text property of Label to

First(ColTasksH).Task_ID

 

FakeHungry
New Member

Hi @StalinPonnusamy 

 

Thanks for your suggestion, but it didn't work. The result should be as table below.

FakeHungry_0-1634436628015.png

StalinPonnusamy
Community Champion
Community Champion

Hi @FakeHungry 

 

ClearCollect(
    ColTasksH,
    GroupBy(
        Sort(
            Filter(
                [@TasksH],
                Request_Date >= StartDateH_1.SelectedDate && Request_Date <= EndDateH_1.SelectedDate && 'Vehicle_S/N' = SNSearch_1.Text
            ),
            OT,
            Descending
        ),
        "Request_Date",
        "RequestDateTable"
    )
);
ForAll(
    ColTasksH,
    Collect(
        ColTasksHNew,
        {
            Request_Date: ThisRecord.Request_Date,
            OT: First(ThisRecord.RequestDateTable).OT,
            Task_ID: Concat(ThisRecord.RequestDateTable,Task_ID,",")
        }
    )
)

StalinPonnusamy_0-1634478315495.png

Source

StalinPonnusamy_1-1634478405011.png

 

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,860)