# Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Uploads getting stuck in the virus scanner. We are investigating.
cancel
Showing results for
Did you mean:
Highlighted
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
Highlighted
MVP

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))`
Highlighted
MVP
You don't want to see 2008 or lower year? may be this
Sum({<Year = {">2008"}>}[amount)
11 Replies
Highlighted
MVP
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?
Highlighted
Contributor

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

Highlighted
MVP

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))`
Highlighted
Contributor

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

Highlighted
MVP

Perform this in the script to create a new field

`year([DEFAULT DATE]) as Year`
Highlighted
Contributor

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..

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

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

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