cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rwittels
Helper III
Helper III

Need assistance with sort by date when Gallery is filtered

Hi. My issue is related to 3 of my source data columns:

  1. Date - the date an item was created/opened
  2. 'Date Closed' - the date an item was closed
  3. Status - items have a status of either "Open" or "Closed"

I have set up my Gallery with a button which filters results by status.  When the list is displaying "Open" items, the SortUpDown button sorts by Date perfectly. When the list is displaying "Closed" items, I want the SortUpDown button to sort by 'Date Closed', which is not working.

 

Here is my setup:

OnStart, I declare a global variable: Set(varStatus, true)

The button which filters results by status has this OnSelect property: UpdateContext({varStatus: !varStatus})

One of the labels in my gallery displays the date. The Text property on it is:

If(ThisItem.Status = "Open",Text(ThisItem.Date,"[$-en-GB]yyyy/mm/dd hh:mm"),Text(ThisItem.'Date Closed',"[$-en-GB]yyyy/mm/dd hh:mm"))

The original property was ThisItem.Date which is part of my issue.

When "Open" items are listed, the date displayed is Date.

GalleryDate.jpg

 

 

 

 

 

When "Closed" items are listed, the date displayed is 'Date Closed'.

GalleryDateClosed.jpg

 

 

 

 

 

This is where I need the help

My Gallery Items property is:

SortByColumns(Filter(Main,If(varStatus,Status="Closed",Status="Open"), TextSearchBox1.Text in If(varStatus,'Date Closed',Date) || TextSearchBox1.Text in Location || TextSearchBox1.Text in Issue),"Date",If(SortDescending1,Descending,Ascending))

 

Where the column is specified as "Date", I need it to be "Date Closed" if the Status="Closed". That way it will sort by 'Date Closed' instead of Date, which is not valid on the "Closed" items screen. I have tried many If Statements which all seem logical to me but the problem is that it keeps telling me that "The specified column 'Date Closed' does not exist". I assume it is because the 'Date Closed' field was not added to my gallery, only Date.

 

So, do I need to add the 'Date Closed' field and simply hide Date when "Closed" items are displayed? Is there an easier way?

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @rwittels ,

 

Could you please share more details about the Items of the Gallery? Is that Main a collection?

 

If so, 'Date Closed' field is necessary to add into the collection then you could filter by that field. It would not be complex with the two fields:

 

1\  Use 2 Labels to display the respective field, Date:

 

Text(ThisItem.Date,"[$-en-GB]yyyy/mm/dd hh:mm")

 

 

 and Date Closed: 

 

Text(ThisItem.'Date Closed',"[$-en-GB]yyyy/mm/dd hh:mm")

 

 

2\ Make the 2 Labels overlap.

 

3\ Set Visible of the Date Label: !varStatus, Date Closed Label: varStatus

 

4\ Modify the formula in Gallery Items:

 

SortByColumns(Filter(Main,If(varStatus,Status="Closed",Status="Open"), TextSearchBox1.Text in If(varStatus,'Date Closed',Date) || TextSearchBox1.Text in Location || TextSearchBox1.Text in Issue),If(varStatus,"Date Closed","Date"),If(SortDescending1,Descending,Ascending))

 

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

1 REPLY 1
v-jefferni
Community Support
Community Support

Hi @rwittels ,

 

Could you please share more details about the Items of the Gallery? Is that Main a collection?

 

If so, 'Date Closed' field is necessary to add into the collection then you could filter by that field. It would not be complex with the two fields:

 

1\  Use 2 Labels to display the respective field, Date:

 

Text(ThisItem.Date,"[$-en-GB]yyyy/mm/dd hh:mm")

 

 

 and Date Closed: 

 

Text(ThisItem.'Date Closed',"[$-en-GB]yyyy/mm/dd hh:mm")

 

 

2\ Make the 2 Labels overlap.

 

3\ Set Visible of the Date Label: !varStatus, Date Closed Label: varStatus

 

4\ Modify the formula in Gallery Items:

 

SortByColumns(Filter(Main,If(varStatus,Status="Closed",Status="Open"), TextSearchBox1.Text in If(varStatus,'Date Closed',Date) || TextSearchBox1.Text in Location || TextSearchBox1.Text in Issue),If(varStatus,"Date Closed","Date"),If(SortDescending1,Descending,Ascending))

 

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

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

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

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

Top Solution Authors
Top Kudoed Authors
Users online (53,714)