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

How to put both -ve and +ve value in same bar chart

In a column of a table if contains both -ve and +ve value how we can put both -ve and +ve value in bar chart.

31 Replies
Not applicable
Author

Sorry Hussain! It's not working too. Please find the error message "SQL error: 'Previous' is not a recognized built-in function name"

shumailh
Creator III
Creator III

Are you using sql server as a backend? qlikview functions will not work under SQL command. you need to read the sql data table using qlikview load and apply the function.


sales_live:
SQL SELECT YEAR, SALES FROM [stk_sales];
sales_master:
load year, sales, sales-previous(sales) as variance resident sales_live;
drop table sales_live;


Not applicable
Author

Hi

Sorry about that, I missed something quite important off that function, use the RangeSum function along with Above function as per something like this:

Sum(SalValue) - RangeSum(Above(Sum(SalValue),1,1)

The values for 1,1 are Offset and RowCount where 1 as an offset means start counting at 1 row above (-1 would mean 1 row below, 0 would mean current row) and the row count is 1 which means count only 1 row, if you wanted to count everything up to current row then replace this with RowNo().

I use this all the time in bar charts.

shumailh
Creator III
Creator III

I tried this on graph, it works


=(Sales) - above(Sales)


Not applicable
Author

Hi

That will work but only if you are analysing pre-aggregated values, if you want to use the Sum of a value minus the sum of a previous value then you're going to have to use the RangeSum function.

shumailh
Creator III
Creator III

Thanks Nigel,

I agreed.

Regards,
Shumail Hussain

Not applicable
Author

Hello Nigel! I tried your method but it is not giving the expected result. I mean it is giving incorrect variance. Please let me know if you have any other solution if you have any.

Not applicable
Author

Can you post an example of your app?

Not applicable
Author

I have attached the screen shot. Please find difference in the value. Variance is the one which is required and Variance-1 is the one which i got after using yours. I will post the application little later.

shumailh
Creator III
Creator III

No attachement is there... can you share us an example?

Regards,
Shumail Hussain