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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
qliker3
Creator
Creator

Histogram function

Hi, i have this example data: 

product amount timestamp SNr

a               30             01.01             10

b               40             01.01             10

a               30             01.01             12

b               50             01.01             12

a               30             02.01             11

b               25             02.01             11

etc...

i want to make a histogram that sums the amounts of each product (later it should be possible to filter out products).

Ex: 70, 24, 22 etc.

The histogram should show the frequency of each sum

My idea is 

=aggr(sum(amount), timestamp, SNr, product )

why dosent this work? 

1 Solution

Accepted Solutions
KGalloway
Creator II
Creator II

I don't know that this is possible with a histogram. They are usually meant for looking at the distribution of values in a given field. You would need to create a field that had the summed amounts grouped by timestamp and SNr (ignoring product) but also they need to remember which part of the summed amount was associated with which product. I may be missing something, but I don't think this is possible.

I was able to approximate what I think you are looking for with a bar chart.

KGalloway_0-1674742769286.png

This bar chart has aggr(sum(amount), timestamp, SNr) as the dimension and count(aggr(sum(amount), timestamp, SNr)) as the measure. I then changed the settings of the x-axis to use a continuous scale:

KGalloway_1-1674742853106.png

 

View solution in original post

5 Replies
KGalloway
Creator II
Creator II

Do you need to aggregate the sum across all those fields? When I create a histogram with just "amount", I get the following:

KGalloway_0-1674511576661.png

The data used is shown in the table. Will this work? If not, could you clarify your requirements a little. What data do you want to see the distribution of?

qliker3
Creator
Creator
Author

no, for example: for SNr 10 and timestamp 01.01: a + b = 30 + 40 = 70 etc.

 

sql : SELECT date(timestamp) as datetest, SNr, SUM(amount) as sumamount
FROM table
GROUP BY date(timestamp), SNr

 

i cant use this because i want to be able to filter the data by product

KGalloway
Creator II
Creator II

I don't know that this is possible with a histogram. They are usually meant for looking at the distribution of values in a given field. You would need to create a field that had the summed amounts grouped by timestamp and SNr (ignoring product) but also they need to remember which part of the summed amount was associated with which product. I may be missing something, but I don't think this is possible.

I was able to approximate what I think you are looking for with a bar chart.

KGalloway_0-1674742769286.png

This bar chart has aggr(sum(amount), timestamp, SNr) as the dimension and count(aggr(sum(amount), timestamp, SNr)) as the measure. I then changed the settings of the x-axis to use a continuous scale:

KGalloway_1-1674742853106.png

 

qliker3
Creator
Creator
Author

thanks that works, but for some reason i was getting a lot of 0 in dimension. I have fixed it with an "if". Do you have any idea what could i be getting zeros? 

KGalloway
Creator II
Creator II

I can't say for sure without knowing more about the data. Could you share a sample of the data that produces 0s?