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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
danialier
Creator III
Creator III

Formula does not work


Hello,

Can anyone help me on that ? I have a Bar Chart where I want to show the evolution of the hardware units but in each column (so in each month) I want to show the delta of units from the current month vs the previous one.

As an example, if I have: January 22units sold / Februrary 32 units sold / March 15 units sold. Then I want the columns to show a bar as follows: February a total of +10units (this is 32-22 units) and March a total of -17units (this is 15-32 units).

I'm using the following formula but it does not work...

 

=num(sum({<Product={'Hardware'},Month={$(=Month)}>}Units) - sum({<Product={'Hardware'},Month={$(=(Month)-1)}>}Units))

Thanks!

dani

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

As others have said, you cannot use set analysis in this context, but Above() may be what you need if you want to do the calculation in an expression and not in script. Something like this

=sum({<Product={'Hardware'}>}Units) - Above(sum({<Product={'Hardware'}>}Units))

(Above(TOTAL ...) if you have multiple dimensions)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

7 Replies
nilesh_gangurde
Partner - Specialist
Partner - Specialist

Hi,

in set analysis it will not work.

you can calculate one more field at script level which will show the value after subtraction.

-Nilesh

Not applicable

You are not able to use set analysis in this case.

Either

1. Handle in load script level.

2. Create another expression and make it invisible.

    Invisible Express (Helper): sum({<Product={'Hardware'}>}Units)

    Actual Express for bar chart: =Helper - Above(Helper)

Not applicable

Dani,

Set Analysis are computed ONCE per chart. They cannot return different values according to the row or column of the chart. So, it will certainly not work.

If you want different result per line/row:

You will need to use functions like above() or before()

You will need to modify your model. See a doc I have written on that topic: http://community.qlik.com/docs/DOC-4821

Fabrice

veidlburkhard
Creator III
Creator III

Hi Dani, why don't you calculate the shift in the script and use the simple expression (Units Sold - Shift) in your bar chart.

See example below:QVTEST.jpg

PrashantSangle

Hi,

try this

=num(sum({<Product={'Hardware'},Month={'$(=Month)'}>}Units)) - num(sum({<Product={'Hardware'},Month={$(=Month(MonthStart(Max(Date))-1))}>}Units))

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

As others have said, you cannot use set analysis in this context, but Above() may be what you need if you want to do the calculation in an expression and not in script. Something like this

=sum({<Product={'Hardware'}>}Units) - Above(sum({<Product={'Hardware'}>}Units))

(Above(TOTAL ...) if you have multiple dimensions)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
danialier
Creator III
Creator III
Author

many thanks all !!! issue resolved