Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

FirstSortedValue

Hi all,

Is there a way to get First non zero sorted value?

MonthData
Jan100
Feb100
Mar300
Apr600
May100
Jun700
Jul200
Aug0
Sep0
Oct0
Nov0
Dec0

If the data is as above and my expression is FirstSortedValue(Data,-Month) i would get 0.

But i want 200 which is the firstNONZEROsortedvalue from the last.

Can i get some help here?

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Why dont you load the non zero values and then find the first sorted value.

     Something like this.

    

     Noconcatenate

     Load *,Firstsortedvalue(Data,-Month) as Value resident Data where Data <> 0;

     Drop table Data;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Why dont you load the non zero values and then find the first sorted value.

     Something like this.

    

     Noconcatenate

     Load *,Firstsortedvalue(Data,-Month) as Value resident Data where Data <> 0;

     Drop table Data;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
whiteline
Master II
Master II

Hi.

It seems you could just use set analysis to calculate FirstSortedValue over the records where Data<>0.

Something like: FirstSortedValue({<Data={'=Data>0'}>} Data,-Month)

Not applicable
Author


Hi Whiteline,

Your solution works for the sample data i provided.But, i had lot of other calculations in the actual scenario.Did not work in my cse.

Thanks for your reply and your time:)

Thanks and Regards,

Pavan