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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
DWolsie
Contributor III
Contributor III

Multiple filters on the same field when Summing

Hello everyone,

I've got a problem that seems too simple to solve but I can't find the solution online, perhaps due to wording.

I'm trying to add two custom variables to a Date field to create a Range of Dates.

DWolsie_0-1738146766951.png

This creates the following effective Formula:

DWolsie_1-1738147119683.png

However, I believe this does not create the desired outcome, as I beleive the two BUDAT filters aim to compliment eachother. Based on excess values I receive for this KPI, I believe this combination of filters automaticaly selects all Data. Is there a different way use multipe filters, maybe with an "and" instead of commas?

 

Thanks in advance!

Labels (2)
1 Solution

Accepted Solutions
Aditya_Chitale
Specialist
Specialist

try this:

sum({$<[BUDAT]={$(vPeriodMin)}> * $<[BUDAT]={$(vPeriodMax)}, [BLDAT]={$(vMinDate)}>} WTGBTR)

Regards,

Aditya

View solution in original post

6 Replies
Aditya_Chitale
Specialist
Specialist

try this:

sum({$<[BUDAT]={$(vPeriodMin)}> * $<[BUDAT]={$(vPeriodMax)}, [BLDAT]={$(vMinDate)}>} WTGBTR)

Regards,

Aditya

marcus_sommer

Try it in this way:

sum({$<[BUDAT]={">=$(vPeriodMin)<=$(vPeriodMax)"}, [BLDAT]={$(vMinDate)}>} WTGBTR)

by excluding the comparing-operators from the variable.

DWolsie
Contributor III
Contributor III
Author

How would it look if I wanted to apply two ranges? Say:

Sum({$<[BUDAT]={$(vPeriodMin)}, [BUDAT]={$(vPeriodMax)},

[BLDAT]={$(vPeriodMin)}, [BLDAT]={$(vPeriodMax)}>}WTGBTR)

marcus_sommer

I never tried an approach like:

Sum({$<[BUDAT]={$(vPeriodMin)}, [BUDAT]={$(vPeriodMax)}>}WTGBTR)

which might logically be functional by comparing against >= <= ranges. It would be depending if the selection-engine combined both AND linked sets or applied them in an order.

Even if there are possibilities to apply the wanted conditions in this way I wouldn't go in this direction else using a field only once within a single set-part because like above shown it's possible to define several values and/or ranges against a single field. Therefore I would use:

sum({$<[BUDAT]={">=$(vPeriodMin)<=$(vPeriodMax)"},
             [BLDAT]={">=$(vPeriodMin)<=$(vPeriodMax)"}>} WTGBTR)

DWolsie
Contributor III
Contributor III
Author

Unfortunatley, your solution above gives me the following error message:

DWolsie_0-1738158969685.png

For reference, my variables are now built like this:

DWolsie_1-1738159008265.png

 

marcus_sommer

I think it's caused from the way how the variables are created and that they itself contain quotes. Quotes within variables are possible but creating and calling them in the wanted context in the right way could become quite tricky. Further, concatenating strings or numbers with further numbers will create a string regardless how the result may look like.

I suggest to skip all these troubles and efforts and to apply all kind of matching and calculating only against pure numbers which may in regard to your first variable be something like this:

floor(makedate($(vMinYear), 1, 1))

As dimensions and selections it's fine to use strings or formatted numbers but they have serious disadvantages within any kind of an evaluation. And duplicating all necessary period-fields in n versions within a master-calendar is quite easy and will simplify the life a lot.