Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Asanchez77
Contributor
Contributor

how to make a year bar chart whit the minus year equal of the sum of values of the rest

i have a lot of dates with an amount , i want to create a bar chart by year thats shows the amount of each year, and in the year 2008 i want to sum the amounts of year 2008 and the previus 2007 2006 2005...

 

 

2 Solutions

Accepted Solutions
sunny_talwar

May be like this

If(Year = 2008, Sum(TOTAL {<Year = {"<=2008"}>} Measure), Sum(Measure))

If this is something you want to do based on selection...then may be this

If(Year = Min(TOTAL Year), Sum(TOTAL {<Year = {"<=$(=Min(Year))"}>} Measure), Sum(Measure))

View solution in original post

sunny_talwar

You don't want to see 2008 or lower year? may be this
Sum({<Year = {">2008"}>}[amount)

View solution in original post

11 Replies
sunny_talwar

So, 2009 would be the sum of all years from 2009, 2008, 2007, 2006, 2005 and 2010 will be sum of 2010, 2009, 2008, 2007, 2006, 2005...? Is this what you want?
Asanchez77
Contributor
Contributor
Author

almost, only 2008 its the sum of the rest of years (2007,2006,2005....) 2009 2010 etc only the sum of that year

thanks for the answer

sunny_talwar

May be like this

If(Year = 2008, Sum(TOTAL {<Year = {"<=2008"}>} Measure), Sum(Measure))

If this is something you want to do based on selection...then may be this

If(Year = Min(TOTAL Year), Sum(TOTAL {<Year = {"<=$(=Min(Year))"}>} Measure), Sum(Measure))
Asanchez77
Contributor
Contributor
Author

I used it in a test data with only year in date field and it works, but mi data have 00/00/0000 format, i tried to use the function year but i makes me an error 

 

if(year([DEFAULT DATE])=2008,sum(TOTAL{<year([DEFAULT DATE])={"<=2008"}>} [amount]), Sum([amount)/1000000)

the second year makes the error in set modifier expresion

thanks for the answer

sunny_talwar

Perform this in the script to create a new field

year([DEFAULT DATE]) as Year
Asanchez77
Contributor
Contributor
Author

that works , thank so much, i have another issue, i need only apears year betwen 2008 and the max, i fixed the data in 8 to make that ,but when i selected a field it shows years like 2000 1998..

sunny_talwar

I don't think I understand the issue. Would you be able to explain with an example?
Asanchez77
Contributor
Contributor
Author

if there are more years in the x axis below 2008 i want to dont show only the bars wich value are 2008 or greater

sunny_talwar

You don't want to show 2008 or greater? I am still not sure I understand what the goal is