Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sakthi266
Contributor III
Contributor III

Value Based on the Date Selection compared to Previous Date - Qliksense

Hi All, 

     I need a script to find the value based on date selection and comparing the previous dates and with the unique ID Column. 

 

Eg. Attached for the reference.

 

  Please help ASAP as i am searching for the solutions for implementing in the client.  

 

Regards, 

Sakthivel.S

 

Labels (1)
1 Solution

Accepted Solutions
chrismarlow
Specialist II
Specialist II

Hi,

Sorry for the dealyed reply, this response did not hit my feed.

For a KPI you need to wrap an AGGR round the function depending on what dimesnions you aggregate over, so something like;

sum(aggr(
If(Only({<DATE=>}DATE)=Max({<DATE=>}TOTAL <ID>
If(isnull(GetFieldSelections(DATE)),
DATE,
If(DATE<=GetFieldSelections(DATE),DATE))),Sum({<DATE=>}Amount),Null())
,ID, DATE))

Cheers,

Chris.

View solution in original post

5 Replies
Taoufiq_Zarra

@sakthi266  can you elaborate more ? for exemple why 0 in :

528-Apr-19TYPE12000
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
chrismarlow
Specialist II
Specialist II

Hi,

This might be a start, not sure on zero vs nulls though (& as @Taoufiq_Zarra  says a bit more info on the requirement would help ...)

If(Only({<DATE=>}DATE)=Max({<DATE=>}TOTAL <ID>
If(isnull(GetFieldSelections(DATE)),
DATE,
If(DATE<=GetFieldSelections(DATE),DATE))),Sum({<DATE=>}Amount),Null())

EDIT - note this is not a script function - rather a chart, not sure you would do this in a script given you want this to change with date selection...

Cheers,

Chris.

sakthi266
Contributor III
Contributor III
Author

Hi Tauofiq_Zarra, 

             As mentioned, we have multiple Rows with same id (which is 5) when we are in 5th-July-2020. So we have to take maximum date value. 

 

Regards,

Sakthivel.S

 

sakthi266
Contributor III
Contributor III
Author

Hi, 

      This is working fine. but the problem is if i give the expression in KPI it won't work as it was a character. I want to sum up the value in KPI Chart 

chrismarlow
Specialist II
Specialist II

Hi,

Sorry for the dealyed reply, this response did not hit my feed.

For a KPI you need to wrap an AGGR round the function depending on what dimesnions you aggregate over, so something like;

sum(aggr(
If(Only({<DATE=>}DATE)=Max({<DATE=>}TOTAL <ID>
If(isnull(GetFieldSelections(DATE)),
DATE,
If(DATE<=GetFieldSelections(DATE),DATE))),Sum({<DATE=>}Amount),Null())
,ID, DATE))

Cheers,

Chris.