Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum a Value with most recent reload date

I am currently reloading data daily, I am trying to Sum a value for the most recent day for the most recent month? What's the best way to add this into set analysis if possible

8 Replies
sunny_talwar

May be this:

Sum({<Date = {"$(=Date(Max(Date), 'YourDateFieldFormat'))"}>}Value)

Not applicable
Author

Sunny,

Won't this return the last date in the field, which would be Sunday? I would need the last reload date.

NickHoff
Specialist
Specialist

In your main create a variable such as

LET vLoadDate = Today();

Then create an inline table to read the load date, store this into a .qvd then read this .qvd at a later time in your script.

LoadDate:

LOAD  * INLINE [

LoadDate

$(vLoadDate) AS LoadDate

];

STORE LoadDate INTO ..\..\.qvd;

Use set analysis to have your Date = LoadDate Field

sunny_talwar

Create a variable like Nick just mentioned:

LET vLoadDate = Date(Today());

and on the front end, may be use this:

Sum({<Date = {"$(vLoadDate)"}>}Value)

Clever_Anjos
Employee
Employee

What about this?

FirstSortedValue(YouValue,-YourDateTimeField)

Not applicable
Author

I created the Variable, but this is summing the value across the data set to date. I only want month to date on the last reload date.

NickHoff
Specialist
Specialist

You need to write the date to a .qvd as I suggested above, otherwise the variable will always read todays date not the actual load date. 

NickHoff
Specialist
Specialist

You didn't mention month to date though, that will change your set analysis to using a current load month indicator in your applications calendar such as:

IF(monthstart(LoadDate) = monthstart(today()),1,0) AS CurrentLoadMonthIND,

Use the following set to get the current load month to date on your load

SUM({$<CurrentLoadMonthIND = {'1'}>}Field)