Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
retko1985
Creator II
Creator II

YTD for bar chart

Hello,

here is a problem I am facing, look at the provided QVW. (Inline Load)

I tried to make an expression, but it is not working. There are two problem.

1) When I select One Month and two years, I want to have 2 Bars - 2016 2 and 2017 2. Now I have bars for each year and each month till selected month.

2) numbers are incorrect, since 2017 2 has to have 40 (20 + 20).

Please help me.

Thank you.

13 Replies
YoussefBelloum
Champion
Champion

Hi,

just added an aggregation function by Year

Aggr(YOUR_EXPRESSION, Year)

Find attached the solution.

Hope it helps !

YB

retko1985
Creator II
Creator II
Author

Hi, this works fine if I have one month Selected (And thank you for this). But is is not working when I have 2 Years and More  than 1 Month selected. I want to have a bar for each Year/Month.

Like if I select Years 2016 and 2017 + Month 1 and 2 I want to see 4 bars.

Can you please help me with that.

Thank you very much!

YoussefBelloum
Champion
Champion

Yes, just add the Month in the aggregation.

find attached

YB

sunny_talwar

May be this

Aggr(RangeSum(Above(Sum({<Year, Month>}Sales), 0, RowNo())), Year, Month)

retko1985
Creator II
Creator II
Author

Hi,

It displays fine, but numbers are incorrect.

Should be like this:

Thank you.

upaliwije
Creator II
Creator II

Hi Sunny

Can you elaborate me what the following part in expression do

RowNo()

pradosh_thakur
Master II
Master II

Hi

Rangesum will give you the sum for all listed value. The value will be provided by above. Which by definition will return you sum of sales from 0(current) to row no (the number of row above).

Rowno()  returns the no of row you are in.

Regards

Pradosh

Learning never stops.
retko1985
Creator II
Creator II
Author

Hello,

thank you for this, but I kinda have an issue here. It works great in model example that I created, but when I use it in my application, it doesn't work, and it kinda gives me the headaches already .

I don't get it, I copied entire chart, changed just the name of the field, and it even don't give me the right number when I choose only January 2017. Weird is that the March is correct, and for January it is Original January sum + sum for March.

I guess you don't have the suggestions here?

Thanks..

pradosh_thakur
Master II
Master II

Hi

first of all you need to check your data how it is loaded. here jan is loaded first then feb and then march and so on .

may be in your app that is not the case.

try putting it in a straight table and see how it is getting loaded which one first and which one next. you can use the fast change option to covert it into a straight table too and check the loading sequence. may be filter it by year to see the exact sequence.It will surely match then way it is getting loaded to your chart . you can share the screen shot too.

regards

Pradosh

Learning never stops.