Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
aswinnar
Partner - Contributor III
Partner - Contributor III

Restricting to first visit

I have a requirement where I need to show a graph of the number of new visits per month for a study

So for a Study A, for visits we have to use the visit types which are shown as:

V0 

V1

V2

V3

V4

 

V0 for example would be the new visits that I am needing to use for my chart. Other studies have different visit types for new visits like T0, or V1. What expression can I use to show the count of the first visit type? 

 

For example, for study A if I take count of v0 for Jan I should get 24, but with the expression that I am using: 

 

=Count({$<visittype={$(=min(visittype))}>}visittype)

I am getting 0, not 24. Is there something wrong with the expression that I am using? 

Labels (2)
10 Replies
MayilVahanan

HI @aswinnar 

V0, V1 is the string. so you can try with Minstring()  function

=Count({$<visittype={'$(=Minstring(visittype))'}>}visittype)

or

Create a flag or dual function to calculate it. 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
aswinnar
Partner - Contributor III
Partner - Contributor III
Author

Hi @MayilVahanan , 

 

That seems to be working, however when applying to my line chart instead of showing multiple lines for each study I am only getting one line now. Is there a reason for this? If I filter for each one they show, and if I use an expression such as 

 

=Count({$<visittype+={'$(=Minstring(visittype))'}>}visittype)

 

All the lines for the studies show, but not the case for the expression you gave. Any reason why?

MayilVahanan

Hi @aswinnar 

Can you provide the sample data and expected output. so that, its help to understand better.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Stone544
Contributor
Contributor

Thanks for the information keep sharing MyGiftCardSite

aswinnar
Partner - Contributor III
Partner - Contributor III
Author

Hi @MayilVahanan 

PFA excel file containing sample data that I am using for the graph 

I am trying to create a multi line chart based on new visits per month for a study. The line graph should show multiple lines, for each study. The issue I had come across was implementing the logic to get the min visits (new visits), using the expression Count({$<visittype+={'$(=Minstring(visittype))'}>}visittype)

 

Using that expression, I am only getting a single line, the other lines for the other studies are not showing up. 

 

In the line chart I am also using an aggregated dimension for visit date, as we are showing new visits over 2020 for different studies

 

The calculated dimension is: =aggr(only({<Visit_Date ={"*2020"}>} Visit_Date),Visit_Date)

 

Let me know if you are needing any more details

MayilVahanan

Hi @aswinnar 

You need to add study as Dimension to display multiple lines for study in line chart

like below

MayilVahanan_0-1607226348911.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
aswinnar
Partner - Contributor III
Partner - Contributor III
Author

Hi @MayilVahanan 

 

As shown in the screenshots I have added Study as a dimension in the qlik linechart, but I am still only getting the one line

 

Is there something else that I am doing wrong? Or is it a Qlik Sense bug? I have also tried with the vizlib linechart extension and am encountering the same issue

aswinnar
Partner - Contributor III
Partner - Contributor III
Author

Hi @MayilVahanan , 

I had told you the wrong expression, 

 

I am using 

Count({$<visittype={'$(=Minstring(visittype))'}>}visittype) as the measure, which is causing me problems. 

 

Whenever I use Count({$<visittype+={'$(=Minstring(visittype))'}>}visittype) it is working but I am needing to create chart for Count({$<visittype={'$(=Minstring(visittype))'}>}visittype), so that is should show for only the new visits, not for all the visits.

 

MayilVahanan

Hi @aswinnar 

For sample data, can you say the expected output?

meanwhile, you can try like below also

Sum(Aggr(if(visittype = MinString(Total<STUDY> visittype), 1), STUDY, Visit_Date, visittype))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.