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: 
mario-sarkis
Creator II
Creator II

Date

Hey all,

my question is i have a field of Date and amount for example:

PerioDate : is to field of Date as number

i need to calculate in a BAR CHART

1- Sum({<periodDate=MaxDate>}amount)  (Current date)

2- Sum(({<periodDate=YearAgo>}amount)  (YearAgo)

3- Sum(({<periodDate=LastMonth>}amount)  (Last Month)

Please help


1 Solution

Accepted Solutions
PrashantSangle

Hi,

try below

Sum({<periodDate={"$(=Max(periodDate))"}>}amount)  as Current date

Sum({<periodDate={"$(=AddYears(max(periodDate),-1))"}>}amount)  as YearAgo

Sum({<periodDate={"$(=AddMonths(max(periodDate),-1)"}>}amount) as Last Month

Note: check Dateformat

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

11 Replies
Not applicable

Hi,

Try like below,

Exp: =Sum({<periodDate={"$(=Max(periodDate))"}>}amount)  (Current date)


Calculate field at script level like below,

year(periodDate) as periodDateYear


Then, Take below Dimension & expression under bar chart

Dim:periodDateYear

Exp: =Sum({<periodDateYear={"$(=year(periodDate)-1)"}>}amount)  (YearAgo)


Calculate field at script level like below,

month(periodDate) as periodDateMonth


Then, Take below Dimension & expression under bar chart

Dim:periodDateMonth

Exp: =Sum({<periodDateMonth={"$(=month(max(periodDate))-1)"}>}amount) (Last Month)


SatyaPaleti
Creator III
Creator III

Mario,

Try this

Sum({<periodDate={"$(=Max(periodDate))"}>}amount)  as Current date

Sum({<periodDateYear={"$(=Year(periodDate)-1)"}>}amount)  as YearAgo

Sum({<periodDateMonth={"$(=Month(max(periodDate))-1)"}>}amount) as Last Month

Thank you,

Satya paleti

mario-sarkis
Creator II
Creator II
Author


Hi Satya

if i am in 2/27/2015 and want the summ in 2/27/2014 is the expression of year ago that you gave me will be applicable ?

Thank you,

SatyaPaleti
Creator III
Creator III

Mario,

Try This

Sum({<periodDateYear={"$(=Max(Year(periodDate))-1)"}>}amount)  as YearAgo


Thank you,

SatyaPaleti

PrashantSangle

Hi,

try below

Sum({<periodDate={"$(=Max(periodDate))"}>}amount)  as Current date

Sum({<periodDate={"$(=AddYears(max(periodDate),-1))"}>}amount)  as YearAgo

Sum({<periodDate={"$(=AddMonths(max(periodDate),-1)"}>}amount) as Last Month

Note: check Dateformat

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
mario-sarkis
Creator II
Creator II
Author


hi Max PeriodDate format is num is this still applicable thanks:)

PrashantSangle

Hi,

I think above expression will work for you, If not use Num()

Modify above expression like

Sum({<periodDate={"$(=Max(periodDate))"}>}amount)  as Current date

Sum({<periodDate={"$(=num(AddYears(max(periodDate),-1)))"}>}amount)  as YearAgo

Sum({<periodDate={"$(=num(AddMonths(max(periodDate),-1)))"}>}amount) as Last Month

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
mario-sarkis
Creator II
Creator II
Author

hey Max thank you for your help ,

but i am facing a small problem wich is :

lets say i have the date 2/27/2015 but in on year back i have it as 2/26/2014 i dont have 2/27/2014

so using your expression it will show a zero amount in 2/27/2014 (amount is avaible on day in a month elsa null)

is it possible to create a field that contain YEARMONTH ? if yes how and how can i use it in this expression

Thank you hope that you can help.


PrashantSangle

Hi,

If you want to create YearMonth field then you can use MonthName() it will gives MonthYear

You can also use Date(Fieldname,'YYYYMM') as YearMonth

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂