Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear Experts,
Im a week into my Qilk sense Learning and I'm writing this seeking your help to figure out a solution to the below scenario.
I have a Year field ( 2016,2017,2018 & 2019) and i need to compare sales based on my current year (based on filter selection) to its previous year in a bar chart.
I have tried using this below set expression in Measure
=sum({<Year ={">= $(=max(Year)-1)<=$(=max(year))"}>}Sales)
I can see 2019 and 2018 comparison but when i'm selecting another year for example 2018 its not working and data of all years is being displayed over bar chart. Can you please correct me
Regards,
Gopinath
=sum({<Year ={">= $(=max(v_selectedYear)-1)<=$(=max(v_selectedYear))"}>}Sales)
create a variable v_SelectedYear = max(GetSelectionField(Year))
=sum({<Year ={">= $(=max(v_selectedYear)-1)<=$(=max(v_selectedYear))"}>}Sales)
create a variable v_SelectedYear = max(GetSelectionField(Year))
You don't need greater than / less than. You only want a single year which is:
Sum({$<Year={$(=max(Year)-1)}>} Sales)
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com
Dear Rob, thanks for writing !
This expression gives only the data of one year in the bar chart (2018 in this case), However my requirement is to view both the bars for 2019 and 2018 (If selection year is 2019) and 2018 and 2017 (If the selection year is 2018)
Thank you
Gopinath
Hi @Gopinath213 ,
Please add one more measure into bar chart for max year
Sum({$<Year={$(=max(Year)-1)}>} Sales) -- max-1 year
Sum({$<Year={$(=max(Year))}>} Sales)-- max year
Dear Claudiu,
This way it is working as expected. Thank you very much for your support !
Regards,
Gopinath
Thank you premvihari !
On a related note, If we want the max(year) and -1 details to be as default with out any selections, how can we achieve that ?
Current expressions gives result only after a particular year is selected {Using Getfieldselection}
Thank you in advance - Gopinath