Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis depending on selection

Hi everybody,

I ran in a problem with set analysis, which is not working like I want.

But I guess you can help me pretty fast with it.

What i wanted to do is sum the sales value depending on the selection I make in the Date field. The Order_Date and the Date are not linked so I wanted to do a set analysis to filter the field in my table accordingly.

The thing is that if I select only the max date value which would be today I have to display the sales from yesterday, thats why it is Date-1 in my function as I cannot display todays sales which I actually not have. If the user selects multiple date values the sales should be sumed up over the selected values, therefore $Order_Date=Date.

Variable vDateSelection:

=if(GetSelectedCount(Date)=1, 'Order_Date=Date-1', '$Order_Date=Date')

Function in the table:

sum({<$(vDateSelection)>}Sales)

Especially the part with only one date selected isnt working properly.

I hope you can help here.

Thanks and best regards,

Sebastian

5 Replies
Gysbert_Wassenaar

If you never want to use the max Date value then try something like the intersection of the possible values resulting from the selections with all Date values smaller than the max Date value:

sum({$*<Order_Date={'<$(=Date(max(Date)-1))'}>}Sales)


talk is cheap, supply exceeds demand
sunny_talwar

I am not 100% sure what you are trying to do with your expression. Would you be able to share a sample with expected output?

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

I think you need a set modifier like this in your Set Analysis, which you can have a variable

= '>='& Min([Selected Date]) & '<=' & Max([Selected Date])

Hope this helps

Not applicable
Author

Hey guys,

thanks for the answers so far.

But they didnt help me so far.

I try to explain what I need with an example:

I select the 09.05.2016 which is today (in field Date).

The selection for Order_Date must be the 08.05.2016 as I do not have Sales data for Today.

If I select the 08.05.2016, which is yesterday, it currently shows me the 07.05.2016 then. The ideal solution would be that it shows me then the data from 08.05.2016. So that Order_Date is also 08.05.2016.

If I select multiple dates it should sum up the Sales for those values. E.g. I select 06.05 & 07.05, I want to select the same for Order_Date in the set analysis and sum accordingly.

On the other hand if I select 07.05, 08.05 & 09.05(Today), I only want to sum up values for 07.05 & 08.05 as I do not have values for the 09.05.

I hope that clarifies how it should work.

Thank you in advance

sunny_talwar

May be like this:

If(GetFieldSelections(Date) = 0, Sum({<Date = {"$(=Date(Today() - 1, 'DD.MM.YYYY'))"}>}Sales), Sum(Sales))