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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
qv_bazz_10
Creator
Creator

Total count of field with two condition

Hi guys,

is there a way to have the total count of a field with two condition based on another filtered field and that doesn't change adding other filters? Maybe it's easier to understand with an example:

I have 12 fields named "ANNO_MESE" for each month of the year in this format "201609, 201610" etc

I have a field named "COD_CLASSE_STRUMENTO" with 3 possible values for each type of the field "ID_SITO": "INT", "XXX", "ORA".

I'd like to have the counter (or an expression in chart) of the field "ID_SITO" that always gives me the total of the field "COD_CLASSE_STRUMENTO" but only of the type "INT" and "XXX" (all but "ORA") and that doesn't change if i add other filters, so is basically the count of the "INT" + "XXX" ID_SITO for a determined month of the year ("ANNO_MESE").

I hope to have been as thorough as possible in explaining my need.

N.B. I can't work on the scritp and i can't upload the file because i'm using a shared document.

Thanks in advance,

Andrea

1 Solution

Accepted Solutions
qv_bazz_10
Creator
Creator
Author

Hi Sunny!

I just added "1" at the beginning of the first expression you posted and it works perfectly, you can see it below:

Count({1<COD_CLASSE_STRUMENTO={'XXX','INT'}, ANNO_MESE = P(ANNO_MESE)>} ID_SITO)

Thank you very much for your precious help!

Andrea

View solution in original post

5 Replies
Anil_Babu_Samineni

Bit confusing, what was the problem

Count({<type= {'int'}, ANNO_MESE=>} ID_SITO) + Count({<type= {'xxx'}, ANNO_MESE=>} ID_SITO)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
qv_bazz_10
Creator
Creator
Author

Hi Anil,

first of all, thank you for helping me. I tried your solution but i didn't get the result i was searching for.

Starting from your advice, i took a step forward because i managed to get this expression:

count({1<COD_CLASSE_STRUMENTO={'XXX','INT'}, ANNO_MESE>} ID_SITO)

I inserted it in a pivot chart and i got the total from every "ANNO_MESE" despite subsequent selections. What i need now is the total from the only "ANNO_MESE" selected, take a look at the screenshot below (I highlighted the selected value and the result i'd like to have displayed):

Any advices to complete the task?

Thanks everybody.

Andrea

sunny_talwar

I guess don't ignore all selections (using 1) and selection in ANNO_MESE

Count({<COD_CLASSE_STRUMENTO={'XXX','INT'}>} ID_SITO)

or if you want to ignore all selection, but allow selection in ANNO_MESE, then try this

Count({<COD_CLASSE_STRUMENTO={'XXX','INT'}, ANNO_MESE = P(ANNO_MESE)>} ID_SITO)

or

Count({<COD_CLASSE_STRUMENTO={'XXX','INT'}, ANNO_MESE = $::ANNO_MESE>} ID_SITO)

qv_bazz_10
Creator
Creator
Author

Hi Sunny!

I just added "1" at the beginning of the first expression you posted and it works perfectly, you can see it below:

Count({1<COD_CLASSE_STRUMENTO={'XXX','INT'}, ANNO_MESE = P(ANNO_MESE)>} ID_SITO)

Thank you very much for your precious help!

Andrea

sunny_talwar

Awesome!!

I am glad we were able to resolve this.

Best,

Sunny