cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Need help to sort a date/time column from SP to ascend

Hello!

 

I got this problem where I try to sort on a date/time column (Last contact) from an SP list in Powerapps and for some reason it doesnt work.

 

This code gives no errors but the gallery is just blank:

If('Toggle'.Value;
Filter(
   Sort(
   'Logg';
'Last contact';Ascending);
Agreementarea.Value in "Location1" & "Location2";
Status.Value in "Ongoing" & "Finished"
   );
Filter(
   Sort(
   'Logg';
'Last contact';Ascending);
       Agreementarea.Value in 'Filter agreementarea'.SelectedItems.Value ;
       Status.Value in "Ongoing" & "Finished"
   ))

 

 

What i'm trying to accomplish is that you can filter with a dropdown meny called "Filter agreementarea" or toggle a button and instant get all choices in the agreementarea shown in the gallery

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

 

OK, obviously the formula isn't delegable because of the in operator, not to mention, you have 11K rows data, so I suspect that it's a delegation issue. What you filter exceed the maximum threshold (2000), the gallery only shows blank.

 

If my assumption is correct, here is a workaround for this issue.

1. set OnChange property of "Filter agreementarea" combox as follows, save each selected option into variable.

Concurrent(
    Set(
        v1,
        Last(
            FirstN(
                Self.SelectedItems,
                1
            )
        ).Value
    ),
    Set(
        v2,
        Last(
            FirstN(
                Self.SelectedItems,
                2
            )
        ).Value
    ),
    Set(
        v3,
        Last(
            FirstN(
                Self.SelectedItems,
                3
            )
        ).Value
    ),
    Set(
        v4,
        Last(
            FirstN(
                Self.SelectedItems,
                4
            )
        ).Value
    ),
    Set(
        v5,
        Last(
            FirstN(
                Self.SelectedItems,
                5
            )
        ).Value
    )
)

2. modify the Gallery.Items property as follow, remove In operator, change to user = operator to match each criterion.

If('Toggle'.Value;
Filter( 
   Sort('Logg';'Last contact';Ascending);
Agreementarea.Value = "Location1" ||
Agreementarea.Value = "Location2";
Status.Value = "Ongoing" ||
Status.Value = "Finished"
   );
Filter(
   Sort('Logg';'Last contact';Ascending);
       Agreementarea.Value = v1 || Agreementarea.Value = v2 || Agreementarea.Value = v3 || Agreementarea.Value = v4 || Agreementarea.Value = v5 ||;
       Status.Value = "Ongoing" ||
       Status.Value = "Finished"
   ))

Hope this helps.

Sik

View solution in original post

10 REPLIES 10
WarrenBelz
Super User
Super User

@Anonymous ,

You have just posted the same code that we have spend 26 posts correcting on this thread.

Obviously, you do not wish further assistance from me, but whoever picks this one up needs to know the history or they will be starting from the beginning. Your problem is not your sort - it is your filters, which I believe have already been corrected in the other thread and yet you post the originals code again.

Anonymous
Not applicable

Is there anyone who can help me? 🙂

Anonymous
Not applicable

Hey guys! I really need some help with this. I really appreciate the help!

v-siky-msft
Community Support
Community Support

Hi @Anonymous ,

 

Can the code work properly without any sort() function?  What is the Items property of 'Filter agreementarea' combobox?

The code looks good, if the code without the sort() function can work perfectly, how about trying some other sort functions?

Try this out:

SortByColumns( 
If('Toggle'.Value;
Filter(
   'Logg';
Agreementarea.Value in "Location1" & "Location2";
Status.Value in "Ongoing" & "Finished"
   );
Filter(
      'Logg';
       Agreementarea.Value in 'Filter agreementarea'.SelectedItems.Value ;
       Status.Value in "Ongoing" & "Finished"
   )
);"Last contact";Ascending)

Hope this helps.

Sik 

Anonymous
Not applicable

@v-siky-msft Hello!

 

My code doesnt seem to work when I try without the Sort() function.. 


This is the item property of the "Filter agreementarea" combox:

Choices(Logg.Agreementarea)

 

I tried the code you provided and the gallery is just blank 😞 

Hi @Anonymous ,

 

So, it seems the problem isn't due to the sort function, because the filter formula doesn't even work.

Please share more information about your scenario.

What are the data types of these columns in Logg list? 

How many rows are there in in Logg list? 

Could you please share more snapshots to display what you want to achieve?

 

Sik

Anonymous
Not applicable

@v-siky-msft There is over 11k rows in this sharepoint list, but that what the filter is for.

 

Columns in logg list:

Last contact = an date/time field in SP list where users with a lookup can choose date and time, as seen in the screenshot of my first post.

ThisItem.'Last contact"

Agreementarea = An choice field in SP list where you can only choose 1 alternative out of 5.

Items property:

Choices('Logg'.Agreementarea)

 

Status = An choice field in SP list where you can only choose 1 alternative out of 6.

Item property:

Choices('Logg'.Status)

 

As I explained before, you can choose to either sort by "Sortera på avtalsområde" (Filter agreementarea) or use the toggle to show some other filters, toggle should overwrite the other filter.

 

 last contact ascending pic2.png

@Anonymous ,

I will leave you with @v-siky-msft , but you are being told the same thing I spent 13 posts telling you on this thread.

 

Hi @Anonymous ,

 

OK, obviously the formula isn't delegable because of the in operator, not to mention, you have 11K rows data, so I suspect that it's a delegation issue. What you filter exceed the maximum threshold (2000), the gallery only shows blank.

 

If my assumption is correct, here is a workaround for this issue.

1. set OnChange property of "Filter agreementarea" combox as follows, save each selected option into variable.

Concurrent(
    Set(
        v1,
        Last(
            FirstN(
                Self.SelectedItems,
                1
            )
        ).Value
    ),
    Set(
        v2,
        Last(
            FirstN(
                Self.SelectedItems,
                2
            )
        ).Value
    ),
    Set(
        v3,
        Last(
            FirstN(
                Self.SelectedItems,
                3
            )
        ).Value
    ),
    Set(
        v4,
        Last(
            FirstN(
                Self.SelectedItems,
                4
            )
        ).Value
    ),
    Set(
        v5,
        Last(
            FirstN(
                Self.SelectedItems,
                5
            )
        ).Value
    )
)

2. modify the Gallery.Items property as follow, remove In operator, change to user = operator to match each criterion.

If('Toggle'.Value;
Filter( 
   Sort('Logg';'Last contact';Ascending);
Agreementarea.Value = "Location1" ||
Agreementarea.Value = "Location2";
Status.Value = "Ongoing" ||
Status.Value = "Finished"
   );
Filter(
   Sort('Logg';'Last contact';Ascending);
       Agreementarea.Value = v1 || Agreementarea.Value = v2 || Agreementarea.Value = v3 || Agreementarea.Value = v4 || Agreementarea.Value = v5 ||;
       Status.Value = "Ongoing" ||
       Status.Value = "Finished"
   ))

Hope this helps.

Sik

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (1,384)