Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Correct way to sort multiple column with different order

(1) ShareShare
ReportReport
Posted on by

I am using the below code to sort the date column first and then the number column next but with different ascending,

It does not bring the correct result but not showing any error, below is full code I am using in the default value of the gallery.

 

Kindly advise, my sort order code is correctly written or should be modified 

(it is possible to write multi column sort in one line by comma with different order, as my code has to arrange the data sorting twice)

 

LookUp(
SortByColumns(    
SortByColumns(
colAllWarranty,
"cr333_claimdate",
SortOrder.Descending
),
"cr333_claimno",
SortOrder.Ascending),

(Len(TypeModel_1.Value) = 0 || TypeModel_1.Value in MachineModel) &&
(Len(TypeSerial_1.Value) = 0 || TypeSerial_1.Value in MachineSerial) &&
(Len(TypeClaimNo.Value) = 0 || TypeClaimNo.Value in ClaimNo) &&
(Len(TypeJobDesc_1.Value) = 0 || TypeJobDesc_1.Value in FailureDetails || TypeJobDesc_1.Value in OtherDetails) &&

(
(DateValue(ClaimDate) >= If(IsBlank(DeliverFromDate_2.Value), DatePicker3_2.Value, DeliverFromDate_2.Value))  &&
(DateValue(ClaimDate) <= If(IsBlank(DeliverDateTo_2.Value), DatePicker3_3.Value, DeliverDateTo_2.Value))
)

)
 
 
 
 
Note : the lookup method is been used in my code so that every time and every filter  - the first record to be selected.  Till I was applying only sort by date, it was working fine - The filter was getting applied and was always selecting the first record ,
BUT when I added another column for sort, the problem starter of not bring the correct result
  • Verified answer
    mmbr1606 Profile Picture
    12,112 Super User 2025 Season 1 on at
    Re: Correct way to sort multiple column with different order

    hey @MIA27 

     

    can u try this:

    LookUp(
     SortByColumns(
     colAllWarranty,
     "cr333_claimdate", SortOrder.Descending,
     "cr333_claimno", SortOrder.Ascending
     ),
     (Len(TypeModel_1.Value) = 0 || TypeModel_1.Value in MachineModel) &&
     (Len(TypeSerial_1.Value) = 0 || TypeSerial_1.Value in MachineSerial) &&
     (Len(TypeClaimNo.Value) = 0 || TypeClaimNo.Value in ClaimNo) &&
     (Len(TypeJobDesc_1.Value) = 0 || TypeJobDesc_1.Value in FailureDetails || TypeJobDesc_1.Value in OtherDetails) &&
     (
     (DateValue(ClaimDate) >= If(IsBlank(DeliverFromDate_2.Value), DatePicker3_2.Value, DeliverFromDate_2.Value)) &&
     (DateValue(ClaimDate) <= If(IsBlank(DeliverDateTo_2.Value), DatePicker3_3.Value, DeliverDateTo_2.Value))
     )
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard