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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can you use max() and min(), in round() in a calculated dimension

Hi,

I have been trying to do a histogram with a dynamic dimension so that I always get 15 bars on the x-axis ranging from the minimum possible value to the maximum possible value but can't get it to work.

I have a used Recipe for a Histogram but instead of using a input box to give the BinWidth I want to calculate it so that it always will be 15 bars in the diagram.

I have tried to use:


=round(randNum, ((max(randNum)-min(randNum)/15) ,0.1))


and

=round(randNum, ((max({$} randNum)-min({$} randNum)/15) ,0.1))

as calculated dimension but I get "// Error in Calculated dimension" as a error from the plott. If I use the ALL according to:

=round(randNum, ((max(ALL randNum)-min(ALL randNum)/15) ,0.1))

as dimension I get what I what in the case that no selection is made but not otherwise and why doesn't:

=round(randNum, ((max({1} randNum)-min({1} randNum)/15) ,0.1))


Work even though max({1} randNum) evaluates to the same as max(ALL randNum)?

Could this be solved?

I insert the qvw-file I have been trying on.

Regards

Per

1 Solution

Accepted Solutions
MarcoWedel

Hi,

solutions could be:

QlikCommunity_Thread_163144_Pic1.JPG

Dimension:

=Num(Aggr(Floor(randNum,(max(TOTAL randNum)-min(TOTAL randNum))/15), randNum),'#0,00')

Expression:

=count(randNum)

or

QlikCommunity_Thread_163144_Pic2.JPG

Dimension:

=ValueLoop(min(TOTAL randNum),max(TOTAL randNum),(max(TOTAL randNum)-min(TOTAL randNum))/15)

Expression:

=-Sum(randNum>=ValueLoop(min(TOTAL randNum),max(TOTAL randNum),(max(TOTAL randNum)-min(TOTAL randNum))/15) and randNum<ValueLoop(min(TOTAL randNum),max(TOTAL randNum),(max(TOTAL randNum)-min(TOTAL randNum))/15)+(max(TOTAL randNum)-min(TOTAL randNum))/15)

that even generates bins without occurrences.

QlikCommunity_Thread_163144_Pic3.JPG

hope this helps

regards

Marco

View solution in original post

2 Replies
marcus_sommer

You could use aggregation-functions within a calculated dimension but they must be wrapped in an aggr-function: AGGR...

- Marcus

MarcoWedel

Hi,

solutions could be:

QlikCommunity_Thread_163144_Pic1.JPG

Dimension:

=Num(Aggr(Floor(randNum,(max(TOTAL randNum)-min(TOTAL randNum))/15), randNum),'#0,00')

Expression:

=count(randNum)

or

QlikCommunity_Thread_163144_Pic2.JPG

Dimension:

=ValueLoop(min(TOTAL randNum),max(TOTAL randNum),(max(TOTAL randNum)-min(TOTAL randNum))/15)

Expression:

=-Sum(randNum>=ValueLoop(min(TOTAL randNum),max(TOTAL randNum),(max(TOTAL randNum)-min(TOTAL randNum))/15) and randNum<ValueLoop(min(TOTAL randNum),max(TOTAL randNum),(max(TOTAL randNum)-min(TOTAL randNum))/15)+(max(TOTAL randNum)-min(TOTAL randNum))/15)

that even generates bins without occurrences.

QlikCommunity_Thread_163144_Pic3.JPG

hope this helps

regards

Marco