Hello Randy,
Our Shipping Request gallery is going to grow rapidly. Even if they only get 5 requests per day that is roughly 1,200 requests per year. The only non-delegable formula in my Items property at the moment is the Search formula which has an "in" operator. I set the data row limit to 1000 items for now and will keep an eye on our gallery count. I asked the Logistics Team how far back they need to be able to view records in the gallery. They said 1 year would be enough. Can you help me tweak the formula below to filter out any items that are more than 1 year old from "Today's" date? Thank you, Teresa
With({galItems:
AddColumns(
Filter('Domestic Shipping Requests',
txtSearchBox.Text in Company,
(!ckMine.Value || 'Requestor Name'.Email=varUser.Email),
(!ckAssigned.Value || 'Logistics Staff Member'.Email=varUser.Email),
'Request Date' >=dpFromDate.SelectedDate && 'Request Date' <=dpToDate.SelectedDate
),
"requestors", With({lName: Split('Requestor Name'.DisplayName, " ")},
First(lName).Result & " " & Left(Last(lName).Result, 1) & "."),
"logistics", If(IsBlank('Logistics Staff Member'.DisplayName),
"pending", With({lName: Split('Shipped By'.DisplayName, " ")},
First(lName).Result & " " & Left(Last(FirstN(lName, 2)).Result, 1) & ".")),
"stat", Status.Value,
"method", 'Shipping Method'.Value
)},
DropColumns(
SortByColumns(
Filter(galItems,
(IsBlank(lclFilter.stats) || "All" in lclFilter.stats || Status.Value in lclFilter.stats.Value) &&
If(CountRows(lclFilter.requestors) > 0, requestors in lclFilter.requestors, true) &&
If(CountRows(lclFilter.logistics) > 0, logistics in lclFilter.logistics, true)
),
Coalesce(locSortColumn,"Title"),
If(Coalesce(locSortAscending,true),Ascending,Descending)
),
"requestors",
"logistics"
)
)
Solved! Go to Solution.
Hi @tagustin2020 ,
I will leave the rest to Randy, but I use this all the time as our work is timeline based - just sort the list ID Descending and get the newest xxx (your Delegation Limit) records
With(
{
galItems:
AddColumns(
Filter(
Sort(
'Domestic Shipping Requests',
ID,
Descending
),
txtSearchBox.Text in Company,
. . . . . . . . .
Just until @RandyHayes can pop over to give you your exact code, here's one way singling out the past year can be done in your filter.
Filter(SalesEvalArchive,DATE>DateAdd(Now(),-1,Years)))
Think you should be able to figure out the way to write it for your own project from that 🙂
Hi @tagustin2020 ,
I will leave the rest to Randy, but I use this all the time as our work is timeline based - just sort the list ID Descending and get the newest xxx (your Delegation Limit) records
With(
{
galItems:
AddColumns(
Filter(
Sort(
'Domestic Shipping Requests',
ID,
Descending
),
txtSearchBox.Text in Company,
. . . . . . . . .
Hi Warren and Randy,
I like Warren's suggestion of defaulting the list to descending order for the Request Date column. That makes more sense than the current way I have it which is to default to sorting on the Company (internal Title) column. I think both the Logistics Team and the users will benefit from seeing the latest requests at the top of the queue. Randy, can you help me make that adjustment as well as filtering out anything over a year old? I really appreciate your willingness to help me with the gallery filters until I get good at it on my own. The internal name of my SharePoint column is RequestDate. The Display Name is 'Request Date'.
Thank you,
Teresa
Just until @RandyHayes can pop over to give you your exact code, here's one way singling out the past year can be done in your filter.
Filter(SalesEvalArchive,DATE>DateAdd(Now(),-1,Years)))
Think you should be able to figure out the way to write it for your own project from that 🙂
Hi Warren,
Thank you for the nudge. I was just intimidated, but I gave your formulas a try and was able to get them (filter out anything older than a year and default to descending order) working on my own without pestering Randy any further. Here is the final formula. Let me know if you think I got anything wrong. Have a great day! Teresa
With({galItems:
AddColumns(
Filter('Domestic Shipping Requests',
txtSearchBox.Text in Company,
'Request Date'>DateAdd(Now(),-1,Years),
(!ckMine.Value || 'Requestor Name'.Email=varUser.Email),
(!ckAssigned.Value || 'Logistics Staff Member'.Email=varUser.Email),
'Request Date' >=dpFromDate.SelectedDate && 'Request Date' <=dpToDate.SelectedDate
),
"requestors", With({lName: Split('Requestor Name'.DisplayName, " ")},
First(lName).Result & " " & Left(Last(lName).Result, 1) & "."),
"logistics", If(IsBlank('Logistics Staff Member'.DisplayName),
"pending", With({lName: Split('Shipped By'.DisplayName, " ")},
First(lName).Result & " " & Left(Last(FirstN(lName, 2)).Result, 1) & ".")),
"stat", Status.Value,
"method", 'Shipping Method'.Value
)},
DropColumns(
SortByColumns(
Filter(galItems,
(IsBlank(lclFilter.stats) || "All" in lclFilter.stats || Status.Value in lclFilter.stats.Value) &&
If(CountRows(lclFilter.requestors) > 0, requestors in lclFilter.requestors, true) &&
If(CountRows(lclFilter.logistics) > 0, logistics in lclFilter.logistics, true)
),
Coalesce(locSortColumn,"ReqNumber"),
If(Coalesce(locSortAscending,true),Ascending,Descending)
),
"requestors",
"logistics"
)
)
Hi @tagustin2020 ,
Here is my idea on the structure - note free-typed, so watch commas/brackets etc.
With(
{
galItems:
Filter(
Sort(
'Domestic Shipping Requests',
ID,
Descending
),
) //you need this as the initial "filter" to make the rest Delegable
},
DropColumns( //now put all the rest together
AddColumns(
Filter(
galItems,
(IsBlank(txtSearchBox.Text) || txtSearchBox.Text in Company) && //allow for blank search box
'Request Date'> DateAdd( //then your data filter 1 year
Now(),
-1,
Years
) &&
(!ckMine.Value || 'Requestor Name'.Email=varUser.Email) &&
(!ckAssigned.Value || 'Logistics Staff Member'.Email=varUser.Email) &&
'Request Date' >=dpFromDate.SelectedDate &&
'Request Date' <=dpToDate.SelectedDate && //need to bracket the true part of the below
((IsBlank(lclFilter.stats) || "All" in lclFilter.stats) || Status.Value in lclFilter.stats.Value) &&
(CountRows(lclFilter.requestors) = 0 || requestors in lclFilter.requestors) && //true_false in below
(CountRows(lclFilter.logistics) = 0 || logistics in lclFilter.logistics)
),
"requestors", //just copied your code for add columns
With(
{lName: Split('Requestor Name'.DisplayName," ")},
First(lName).Result & " " & Left(Last(lName).Result, 1) & "."
),
"logistics",
If(
IsBlank('Logistics Staff Member'.DisplayName),
"pending",
With({lName: Split('Shipped By'.DisplayName, " ")},
First(lName).Result & " " & Left(Last(FirstN(lName, 2)).Result, 1) & ".")
),
"stat",
Status.Value,
"method",
'Shipping Method'.Value
), //now the dropped columns
"requestors",
"logistics"
), //now the sort
Coalesce(locSortColumn,"ReqNumber"),
If(
Coalesce(locSortAscending,true),
Ascending,
Descending
)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi Warren,
Thank you for the formula. I can't get it to work. When you are new, it is hard to spot where the breakage is occurring in a long, complex formula like this one. Can you help me out?
Teresa
I need to know what the error is - I was using your code, so it could be a value reference.
Hello Warren,
Apologies for the delay getting back to you on this. I haven't had a chance to work on Power Apps due to other competing work priorities. I'll get back to you as soon as I can on this. I really do appreciate your help. Have a nice weekend and if you are a dad, Happy Father's Day!
Kind regards,
Teresa
User | Count |
---|---|
253 | |
106 | |
94 | |
50 | |
39 |