Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
stabben23
Partner - Master
Partner - Master

Previous first row

Hi,

I have a problem building a flag in script. I have use previous and get a correct output, expect first row.

Here is my table.and this is for changeflag if(previous(dimension)=dimension  ,0,1)

What I want is to get a 1 on the first row With a New Dimension. I think that the first 1 will be there because previous find null and compare it With the first row.

Any trix to avoid this scenario?

1 Solution

Accepted Solutions
kenphamvn
Creator III
Creator III

Hi

using RowNo() like a trick

if(previous(dimension)=dimension or rowno() =1  ,0,1)

View solution in original post

8 Replies
ksomosera10
Creator II
Creator II

Hi,

I think you'll have to use a calculated dimension

for example is like this.


=if(field2='field2value',field1)


Is that good or not?

stabben23
Partner - Master
Partner - Master
Author

Hi Kevin,

this is in script not in a pivot.

ksomosera10
Creator II
Creator II

So you're sayin' this is on the load script?

kenphamvn
Creator III
Creator III

Hi

using RowNo() like a trick

if(previous(dimension)=dimension or rowno() =1  ,0,1)

antoniotiman
Master III
Master III

Hi Staffan,

maybe this

if(previous(dimension)=dimension  or RowNo()=1 ,0,1)

Regards,

Antonio

tresesco
MVP
MVP

You can perhaps just try putting rowno()=1 check like:

if(if rowno()=1 or previous(dimension) <> dimension  ,1 , 0)

stabben23
Partner - Master
Partner - Master
Author

Three similar answer, let give it a try.

stabben23
Partner - Master
Partner - Master
Author

The rowno() check will help me, thanks guys.