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: 
TheresaB_4
Contributor III
Contributor III

Count and AGGR using it as a measure as Dimension

Hi everyone,

My product is Gas and Electricity

I have customers that can have Gas or Electricity or both. I need to see how many customers have either both or just Gas or Electricity.
But each time I get this right it is a measure. I need to add the measure as a column(Dimension).
Or does anyone have another idea of getting the data? I would love to hear it.
I also was thinking doing this in the editor.

CustomerTable

CustomerNumber

ConnectionID

ProductTable

ProductID

ProductDescription

TheresaB_4_0-1704884046443.png

This is what I need in a pivot in Qlik

TheresaB_4_1-1704884120640.png

My measure
=if(count(
{<ProductDescription={'Electricity', 'Gas'}>}
Distinct ProductDescription)>1, 'Dual', 'Single')

 

 

 

Labels (4)
1 Solution

Accepted Solutions
Rohan
Specialist
Specialist

Hi Theresa,

have you used the Concat() Function ? I think you can use something like :

Aggr(Concat( distinct ProductDescription,','),CustomerNumber) as the dimension in the pivot. I think this will solve your issue.

 

Regards,

Rohan.

View solution in original post

6 Replies
TheresaB_4
Contributor III
Contributor III
Author

I got the expression as a dimension but something is wrong because it gives me dashes

TheresaB_4_0-1704890034475.png

=aggr(
if(count(
{<ProductDescription={'Electricity', 'Gas'}>}
Distinct Productdescription)>1), 'Dual', 'Single')

Anil_Babu_Samineni

@TheresaB_4  I don't see that you are aggregating any dimension. Maybe this?

=if(count({<ProductDescription={'Electricity', 'Gas'}>} Distinct Productdescription)>1, 'Dual', 'Single')

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
TheresaB_4
Contributor III
Contributor III
Author

I did make that measure, but I can not use in a pivot.

Maybe I am not asking the right question.
How do I count Distinct CustomerNumbers that has Both Electricity and Gas.

Maybe this is better

Rohan
Specialist
Specialist

Hi Theresa,

have you used the Concat() Function ? I think you can use something like :

Aggr(Concat( distinct ProductDescription,','),CustomerNumber) as the dimension in the pivot. I think this will solve your issue.

 

Regards,

Rohan.

Anil_Babu_Samineni

@TheresaB_4 If that is as dimension

=if(Aggr(count({<ProductDescription={'Electricity', 'Gas'}>} Distinct Productdescription),<All your dimensions that is been used from chart>)>1, 'Dual', 'Single')

Otherwise, the question you asked already deserved with above set expression, since Distinct already there.

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
TheresaB_4
Contributor III
Contributor III
Author

Awesome it works in the pivot, thanks so much Rohan.