Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Any peek-like function in chart or expression?

Hi,

I have a chart that counts distinct users logging in over time. How can I have a text box/table/chart where it shows only new users logging in? i.e. were not logged in in the previous month. e.g. if 10 new users logged in in September, where new is defined as did not ever log in before (or did not log in the previous month), the chart should show 10 for September, instead of 1000 (total unique users in the month).

1 Solution

Accepted Solutions
tresesco
MVP
MVP

It's probably not impossible in chart. But possibility surely going to take you to a much complex expression.  therefore, better to handle such situations in the script itself. Compare it and flag. Then in the front end use the flag to find new users.

View solution in original post

16 Replies
sunilkumarqv
Specialist II
Specialist II

share sample so we can try and help you

sunny_talwar

You can use Below/Above function on the front end. But to give a more appropriate answer, it would be best if you can share a sample.

Best,

Sunny

sasiparupudi1
Master III
Master III

use above/below

above([ total ] expression [ , offset [,n ]])

Returns the value of expression evaluated with the chart's dimension values as they appear on the row above the current row within a column segment in a table or, in the case of bitmap charts, in the chart's straight table equivalent (Actually all QlikView charts have a straight table equivalent with the exception of the pivot table which has a more complex structure.).

On the first row of a column segment a NULL value will be returned, as there is no row above this one.

If the chart is one-dimensional or if the expression is preceded by the total qualifier, the current column segment is always equal to the entire column.

If the table or table equivalent has multiple vertical dimensions, the current column segment will include only rows with the same values as the current row in all dimension columns except for the column showing the last dimension in the inter field sort order. The inter field sort order for pivot tables is defined simply by the order of the dimensions from left to right. For other chart types this can be manipulated in the Chart Properties: Sort dialog.

Specifying an offset greater than 1 lets you move the evaluation of expression to rows further up the current row. A negative offset number will actually make the above function equivalent to a below function with the corresponding positive offset number. Specifying an offset of 0 will evaluate the expression on the current row. Recursive calls will return NULL.

By specifying a third parameter n greater than 1, the function will return not one but a range of n values, one for each of n table rows counting upwards from the original cell. In this form, the function can be used as an argument to any of the special Chart Range Functions.

Examples:

sum( Sales ) / above( sum( Sales ))

above( sum( Sales ), 2 )

above( total sum( Sales ))

   

rangeavg (above(sum(x),1,3))returns an average of the three results of the sum(x) function evaluated on the three rows immediately above the current row.

below([ total ] expression [ , offset [,n ]])

Returns the value of expression evaluated with the chart's dimension values as they appear on the row below the current row within a column segment in a table or, in the case of bitmap charts, in the chart's straight table equivalent.

On the last row of a column segment a NULL value will be returned, as there is no row below this one.

If the chart is one-dimensional or if the expression is preceded by the total qualifier, the current column segment is always equal to the entire column.

If the table or table equivalent has multiple vertical dimensions, the current column segment will include only rows with the same values as the current row in all dimension columns except for the column showing the last dimension in the inter field sort order. The inter field sort order for pivot tables is defined simply by the order of the dimensions from left to right. For other chart types this can be manipulated in the Chart Properties: Sort dialog.

Specifying an offset greater than 1 lets you move the evaluation of expression to rows further down the current row. A negative offset number will actually make the below function equivalent to a above function with the corresponding positive offset number. Specifying an offset of 0 will evaluate the expression on the current row. Recursive calls will return NULL.

By specifying a third parameter n greater than 1, the function will return not one but a range of n values, one for each of n table rows counting downwards from the original cell. In this form, the function can be used as an argument to any of the special Chart Range Functions.

Examples:

below( sum( Sales ))

below( sum( Sales ), 2 )

below( total sum( Sales ))

   

rangeavg (below(sum(x),1,3))

returns an average of the three results of the sum(x) function evaluated on the three rows immediately below the current row.

hth

Sasi

sifatnabil
Specialist
Specialist
Author

Please see attached sample data. the qvw has this data, and I've highlighted the new users (not appearing before in the data). So my end result should be a chart (or text box) that tells me the number of "new" users per month. So it should say April = 0, May = 1, June = 2

  

DateUser
01/04/2014abc
01/04/2014mgd
01/04/2014pqf
01/04/2014iiv
01/04/2014pbr
01/04/2014dsi
01/04/2014upfaah
01/04/2014ukzblg
01/04/2014ukzblg
01/04/2014dggunv
01/04/2014qwumaa
01/04/2014qwumaa
01/04/2014qwumaa
01/04/2014qwumaa
01/05/2014qwumaa
01/05/2014abc
01/05/2014mgd
01/05/2014pqf
01/05/2014iiv
01/05/2014pbr
01/05/2014dsi
01/05/2014upfaah
01/05/2014ukzblg
01/05/2014ukzblg
01/05/2014dggunv
01/05/2014wcmekc
01/06/2014qwumaa
01/06/2014abc
01/06/2014mgd
01/06/2014pqf
01/06/2014iiv
01/06/2014pbr
01/06/2014dsi
01/06/2014upfaah
01/06/2014ukzblg
01/06/2014ukzblg
01/06/2014dggunv
01/06/2014phsmgm
01/06/2014nahujy
Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

I think in this instance you will have to use combination of IF statement and ABOVE function to resolve this.

You have to check the Date & User.

tresesco
MVP
MVP

Create Month field in the script.

Straight table:

Dim: Month

Exp: Concat({<User={"=Count(User)=1"}>} Distinct User, ';')

PFA

sunny_talwar

I think he is looking for a count. Modifying your expression for count:

=Count({<User={"=Count(User)=1"}>} Distinct User)

sifatnabil
Specialist
Specialist
Author

Thanks sunindia‌ and tresesco‌ this works. Could I break down the concat into more rows? e.g.

May 2014wcmekc
Jun 2014nahujy;phsmgm

Should instead be:

May 2014wcmekc
Jun 2014nahujy
Jun 2014phsmgm
sasiparupudi1
Master III
Master III

put User as a dimension

with the expression as suggested above

Count({<User={"=Count(User)=1"}>} Distinct User)


hth

Sasi