Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

businessintelli
New Contributor III

Show Today's month Quantity and Same Day Last Year's month Quantity

Hello,

Today is 15th January,2018. I want to show this month's data on the  bar chart until today  and also last year's data in this month(until 15th of January), I should show the quantity of these data,



To show the data that was on the 15th of January in 2017, I use this formula for the dimension =AddYears(Date(Today()),-1) 


To show the quantity that was in January until today(2018) I use this formula for the measure, that works quite well

=Sum({$<Year={2018}>}Quantity)


But I also want to make the same thing for the last year's data. I wrote this but this doesn't work

Sum({$<Year={{(AddYears(Date(Today()),-1)}}>}Quantity)


Capture.PNG


How can I make it ?

10 Replies
kaanerisen
Contributor III

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

Hi,

You can try this:

Sum({$<[DateField]={">=$(=AddYears(Date(MonthStart(Today())),-1)) <=$(=AddYears(Date(Today()),-1))"}>}Quantity)

Hope it helps,

businessintelli
New Contributor III

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

It doesn't work

I don't need Start of month,I need to sum Quantities for current period Like for 2 weeks that has passed this year and to compare this to the Sum of the same period Last year. For Example today is 15th January  and I want to sum quantities from 1-15 January in 2017 and 2018 and compare this data in the bar chart.

kaanerisen
Contributor III

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

Then, you need the replace monthstart with yearstart if I understand your need correctly.

If you can share your qvf file and the output you desire, I can look into it.

OmarBenSalem
Esteemed Contributor

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

if today is not 15 January, but rather 15 February? What do u want to compare?

1st January 2018 to 15 Feb  2018 and 1st Jan 2017 to 15 Feb 2017

or 1st Feb to 15 Feb 2017 and 2018?

businessintelli
New Contributor III

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

I want to compare 15th February 2017 to 15th February 2018 and 15 March 2017 to 15 March 2018 and etc

OmarBenSalem
Esteemed Contributor

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

what?

how do u want to compare March 2017 to 15 March 2018 while "today's date is 15 Feb 2018" and thus we do not have any data beyond this date???

Highlighted
OmarBenSalem
Esteemed Contributor

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

please try to refer to this thread.

Maybe you'll find in it sthing that could help u :

YTD, MTD issue

businessintelli
New Contributor III

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

For example,  tomorrow in the bar chart there should be 1/16/17 and 1/16/18 and the next day there should be 1/17/17 and 1/17/18 and etc

Like this,

Capture.PNG

pradosh_thakur
Valued Contributor III

Re: Show Today's month Quantity and Same Day Last Year's month Quantity

may be you would like to use valuelist(today(),addyears(today(),-1)) as dimension and sum(quantity) as measure

or

dimension = your date field

expression

Sum({$<[DateField]={" $(=today()),$(=addyears(today(),-1))"}>}Quantity)


please check the date format if required

Community Browser