Not Sorting By Numbers Correctly

Stimulsoft Reports.JS discussion
Post Reply
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Not Sorting By Numbers Correctly

Post by ericp »

I have a report where I'm trying to sort by an Amendment Number. It seems to always be sorting by string only no matter what type I set the datasource to

For some reason, the output when I sort by ascending is showing up as:

100000
11
12
13
14
15
7
8
9

Instead of:

7
8
9
11
12
13
14
15
100000
Attachments
Report.mrt
(26.34 KiB) Downloaded 36 times
Screen Shot 2024-04-05 at 6.06.47 PM.png
Screen Shot 2024-04-05 at 6.06.47 PM.png (434.92 KiB) Viewed 1088 times
Last edited by ericp on Sun Apr 07, 2024 3:39 am, edited 1 time in total.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Not Sorting By Numbers Correctly

Post by ericp »

Also attached my sample report.

I ensured that the type of my source is changed to INT, but it still seems to be sorting by String.
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: Not Sorting By Numbers Correctly

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data for analysis.

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Not Sorting By Numbers Correctly

Post by ericp »

Hi Lech, please see the attached-
Attachments
Report.mrt
(16.39 KiB) Downloaded 31 times
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: Not Sorting By Numbers Correctly

Post by Lech Kulikowski »

Hello,

In your JSON, your column is stored as a string:
"Amendment#": "7"
for numeric should be:
"Amendment#": 7

Also, in your report you can use the following expression for sorting:
(decimal)(Projects.Amendment_)

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Not Sorting By Numbers Correctly

Post by ericp »

Hey Lech, I tried using both (Decimal)(Projects.Amendment_) and {(Decimal)(Projects.Amendment_)}, but it still doesn't seem to be formatting properly.

As for the decimal you can see that i changed the type to decimal- doesn't that automatically make the "Amendment#" turn into 7 instead of "7"?

Are you able to send the report of it working? Thanks!
Attachments
Screen Shot 2024-04-08 at 9.23.18 AM.png
Screen Shot 2024-04-08 at 9.23.18 AM.png (22.16 KiB) Viewed 995 times
Screen Shot 2024-04-08 at 9.22.53 AM.png
Screen Shot 2024-04-08 at 9.22.53 AM.png (437.13 KiB) Viewed 995 times
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: Not Sorting By Numbers Correctly

Post by Lech Kulikowski »

Hello,

Please check the modified report.

Thank you.
Attachments
Report_modified.mrt
(16.83 KiB) Downloaded 24 times
Post Reply