Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
dcd123456
Creator
Creator

set analysis problem

Hello

i have data from several days like this:

   

PERfechauser
ene01/01/2015u1
ene01/01/2015u2
ene02/01/2015u3
ene02/01/2015u4
ene03/01/2015u4
ene04/01/2015u5
ene05/01/2015u6
feb01/02/2015u1
feb01/02/2015u2
feb02/02/2015u3
feb03/02/2015u4
mar01/03/2015u1
mar02/03/2015u2

in want to display , in a bar chart, the count of diferent users agretate by fiel PER(month), but only take the data of the firsts day of each month, the number of days is selected by the user.

y tray to do this with set filter like this:

count({<fecha={"<=$(=date(min(fecha)+$(n_dias)))"}>}DISTINCT user)

n_dias is a variable that hold the number of days.

my problem is that min(fecha) always return one date, the global lowest date 01/0/01/2015, the chart is agregate by PER and i need that the min(fecha) return the min date of each month, not the lowest date.

i have attached an example in a file qvw .

thanks in advance for your help

regards

diego

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

The problem here is that the set (and $ sign expansion) are evaluated at the chart level and not for each dimension value. As there are several possible min dates for the whole dimension the expression will fail.

Try with

count(DISTINCT if(fecha<=date(min_fecha+$(n_dias)),user,null()))

See also attached

View solution in original post

6 Replies
Not applicable

you should have to create another table in the script. This new table will be linked with the fact tables (with user).

This new table should contain the user and his/her min date. You can do it easily just using resident of the fact table and a group by user.

dcd123456
Creator
Creator
Author

Thanks for your answer.

regads

diego

dcd123456
Creator
Creator
Author

Hello

in the script i make a new table that have a new field that is the min date the result is like this

PERfechausermin_fecha
ene01/01/2015u101/01/2015
ene01/01/2015u201/01/2015
ene02/01/2015u301/01/2015
ene02/01/2015u401/01/2015
ene03/01/2015u401/01/2015
ene04/01/2015u501/01/2015
ene05/01/2015u601/01/2015
feb01/02/2015u101/02/2015
feb01/02/2015u201/02/2015
feb02/02/2015u301/02/2015
feb03/02/2015u401/02/2015
mar01/03/2015u101/03/2015
mar02/03/2015u201/03/2015

In the graph i use the next expresion:

count({1<fecha={"<=$(=date(min_fecha+$(n_dias)))"}>}DISTINCT user)

but the graph only show data if i select one value of PER field (a month), if i don't select any value of PER field the graph is empty. And if i select one value of PER field (month) the graph only show the correct value for the value selected, the other PER values show the global count and don't take in account the filter of the set expresion (<fecha={"<=$(=date(min_fecha+$(n_dias)))"}>)

best regards

diego

stigchel
Partner - Master
Partner - Master

The problem here is that the set (and $ sign expansion) are evaluated at the chart level and not for each dimension value. As there are several possible min dates for the whole dimension the expression will fail.

Try with

count(DISTINCT if(fecha<=date(min_fecha+$(n_dias)),user,null()))

See also attached

maxgro
MVP
MVP

I think (if you want the first n_dias days of every month) you should add a day in your model and use that in set analysis

in script add

Day(fecha) as day

expression in chart

count({$<day={"<=$(n_dias)"}>}DISTINCT user)

dcd123456
Creator
Creator
Author

Thanks to all.

Regards

diego