Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Conditional Text objects

I have a group of text objects that display a number via a count expression with some set analysis and a selector box that has the values:Day, Week, Month. I have attached an image of what I have so you might have a better idea of what I am asking.

In the image you will see I have a text object that displays a number for Orders Completed, Abandoned Carts, Total Orders, and I also have a date displayed at the top.

To get the numbers that are displayed, I am doing a count Distinct on the SessionID of the table. Each one also is currently limited to the previous day's numbers.

So for orders completed I have:

=count(DISTINCT{$<SCOrderNumber={"*"}, CreatedOn = {"$(=Date(Today()-1))"}>}SessionID)

With this one I am also filtering by rows that do not have a NULL value in the OrderNumber column.

Abandoned Carts is taking the total of distinct SessionIDs in the table and subtracting the number SessionIDs with an associated non NULL OrderNumber. Which looks like:

=count(DISTINCT{< CreatedOn = {"$(=Date(Today()-1))"} >}SessionID) - count(DISTINCT{$<SCOrderNumber={"*"}, CreatedOn = {"$(=Date(Today()-1))"}>}SessionID)

And total orders is just count distinct of the SessionID with no filter other than the day.

The object for the date is just for my testing to display the date / date range

What I am trying to do is when I click into the day, week, month, is change the date filter in the set analysis. For Day it would be what it is now which is Today()-1, for Week I would want it to be the beginning of the week Sunday or Monday it doesn't matter though today, and Month would be the first of the month through today.

Is there a way to create a variable that will change based on the selection made, that I can then call in the set analysis of the text objects? Or is there perhaps a better way to achieve what I am trying.

Thank you for your help.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I guess your selector is a data island table field with just three values.

What if you extend your table:

LOAD Selector, Exp INLINE [

Selector, Exp

Day, Date(Today()-1)

Week, Weekstart(Today() )

Month, Monthstart(Today() )

];

Then when you make a selection in Selector field values, your set analysis might look like

  1. =count(DISTINCT{$<SCOrderNumber={"*"}, CreatedOn = {"$(=$(=Exp))"}>}SessionID) 

View solution in original post

4 Replies
swuehl
MVP
MVP

I guess your selector is a data island table field with just three values.

What if you extend your table:

LOAD Selector, Exp INLINE [

Selector, Exp

Day, Date(Today()-1)

Week, Weekstart(Today() )

Month, Monthstart(Today() )

];

Then when you make a selection in Selector field values, your set analysis might look like

  1. =count(DISTINCT{$<SCOrderNumber={"*"}, CreatedOn = {"$(=$(=Exp))"}>}SessionID) 
Anonymous
Not applicable
Author

Yes I am using a data island, this seems to be exactly what I would need, and seems extremely simple. I haven't gotten to work quite yet, but I am playing around with it to see if I can get it to work. If I am able to get this to work, I will mare this as the correct answer.

Thank you for you help!

swuehl
MVP
MVP

Well, it should work (it worked in a small sample I just put up), but it might depend on how you are creating your field values and how the dollar sign expansion work upon that.

The Magic of Dollar Expansions

The Little Equals Sign

edit: and remember to select a single Selector value that is linked to a single Exp value.

Anonymous
Not applicable
Author

I have marked your answer as the correct answer, as now that I have worked with it I realize my problem no longer is with getting the dates to switch, but instead to incorporate the date range into the week and month selection.

Again thank you for you help!