Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys,
I am stuck at a point where I want to count the number of entries in a text object.Tried my best but couldn't get a way out to solve this. Any sort of help will be highly appreciated. I have tried explaining my problem below in detail:
There is an expression in text object which will look some thing like :
=Count({<ABC={1}, XYZ={'$(vDRG1)'}, XYZZ = {'$(vDRG1)'}>}ABC) & ',' &
Count({<ABC={2}, XYZ={'$(vDRG1)'}, XYZZ = {'$(vDRG1)'}>}ABC) & ',' &
Count({<ABC={3}, XYZ={'$(vDRG1)'}, XYZZ = {'$(vDRG1)'}>}ABC) & ',' &
.
.
.
all the way till
.
Count({<ABC={60}, XYZ={'$(vDRG1)'}, XYZZ = {'$(vDRG1)'}>}ABC)
The output of this expression will be like: 0,0,2,0,0,0,0.......6,3,0,0,0,0
>> Now I want to get the count of entries till the last non zero values. In the above example it should return = 60-4= 56
Below table will give more clarity
Header 1 | Header 2 | Header 3 | Header 4 | Header 5 | Header 6 | Header 7 | Header 8 | Header 9 | Header 10 | Header 11 | Desired output |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 4 | 7 | 1 | 6 | 0 | 0 | 3 | 10 | |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
0 | 0 | 7 | 7 | 9 | 0 | 2 | 0 | 0 | 0 | 7 |
Thank you,
Sagar Gupta
may be
=substringcount(replace(rtrim(replace('0,0,1,12,0,0,0,10,0,0,0,0,0,0,0', ',0', ' ')),' ', ',0'), ',')+1
replace('0,0,1,12,0,0,0,10,0,0,0,0,0,0,0', ',0', ' ')
rtrim blank --> delete blank (,0) at the rigth of the string
replace(........, ' ', ',0') --> same as initial string but without ,0 at the rigth
substringcount --> count ,
I just got an idea but am not sure how to do that
Cumulative sum from right to left will replace zero values
Hi Sagar,
You will need to repeat your long expression at least twice.
INPUT - 0,0,0,4,7,1,6,0,0,3
substringcount('INPUT', ',') +1 - substringcount(',' & 'INPUT' & ',' , ',0,')
First part gives the number of values. (number of commas + 1)
Second part gives the number of zero values. (Am adding commas at beginning and end of your output so that i can count 0s alone and avoid cases like 10,20,30 etc which also contain a 0.)
may be
=substringcount(replace(rtrim(replace('0,0,1,12,0,0,0,10,0,0,0,0,0,0,0', ',0', ' ')),' ', ',0'), ',')+1
replace('0,0,1,12,0,0,0,10,0,0,0,0,0,0,0', ',0', ' ')
rtrim blank --> delete blank (,0) at the rigth of the string
replace(........, ' ', ',0') --> same as initial string but without ,0 at the rigth
substringcount --> count ,
Hi Grossi,
Thanks a lot, It worked the way I wanted it to be.
Much Thanks