Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Dante_83
Contributor III
Contributor III

Count with KPI's dates

Hello Experts,

I'm trying to use the dates in my KPI to count material. For example, the expression below works well when I want to count material between dates. The problem is that every time I refresh the data, I have to change the date in the expression.

Count({<[Dta Receive]={">=$(='4/30/2021')<=$(='7/21/2021')"}>} COG)

I have several KPI's with this expression "Sum(Aggr(Sum(distinct{<Phase={'Induction'}>} Date([Actual Start Date.autoCalendar.Date])), Phase))" that extract the date I want base on its phases.

Dante_83_0-1653507444021.png

I have tried using , "Count({<[Dta Receive]={">=$(=[Start of Phase 1 Date])<=$(=[End of Phase 1 Date])"}>} COG)". But no success. Does anyone know if this is possible? I appreciate any help you can provide.

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Notice the highlighted part below on the screenshot, your dates are not evaluating

1) Are [Start of Phase 1 Date] and [End of Phase 1 Date] actual fields?

2) If they are fields, what is the format of [Start of Phase 1 Date] and [End of Phase 1 Date]  ?

3) Confirm if the fields are stored as Dates and not Text by  trying these expressions in  a text box

= isnum(min([Start of Phase 1 Date] ))   << if returns 0 means that these are stored as Text, if returns -1 then Date

= isnum(min([End of Phase 1 Date] ))     << if returns 0 means that these are stored as Text, if returns -1 then Date

4) if these are Stored as Text format them to Date while loading Data in script as below

     Date#([Start of Phase 1 Date],'CurrentFormatOfTheField') as [Start of Phase 1 Date]

 

 

qlikCommunity1.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

7 Replies
vinieme12
Champion III
Champion III

Refer this article

https://community.qlik.com/t5/Qlik-Design-Blog/Dates-in-Set-Analysis/ba-p/1472511

 

Count({<[Dta Receive]={">=$(=Date(Min([Start of Phase 1 Date])))<=$(=Date(Max([End of Phase 1 Date])))"}>} COG)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Dante_83
Contributor III
Contributor III
Author

Hello Vinieme12,

Thank you for your help. I've tried the expression and it return zero count. I get an accurate count if I use an expression Count({<[Dta Receive]={">=$(='4/30/2021')<=$(='7/21/2021')"}>} COG). But, I can't get the expression to work with the date in my KPI. The article is helpful.

vinieme12
Champion III
Champion III

 Can you paste the expression you used ?

Not the one where dates are hardcoded 

 

Can you paste a snapshot of the entire expression editor?on the bottom of the expression editor you can see how the expression evaluates and provides insight as to what may be wrong 

 

Also are  [End of Phase 1 Date] and [Start of Phase 1 Date] Are actual fields??

 

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Dante_83
Contributor III
Contributor III
Author

Hello Vinieme12,

Thank you for following up.

KPI's Date

Dante_83_2-1653585150600.png

 

 

Below is my original.

Dante_83_0-1653584626357.png

This one is a suggested Expression.

Dante_83_1-1653584891586.png

 

 

Dante_83
Contributor III
Contributor III
Author

Hello Vinieme12,

Thank you for following up.

KPI's Date

Dante_83_3-1653585317752.png

 

 

 

Below is my original.

Dante_83_4-1653585317755.png

 

This one is a suggested Expression.

Dante_83_5-1653585317758.png

 

Thank you for your help again.

vinieme12
Champion III
Champion III

Notice the highlighted part below on the screenshot, your dates are not evaluating

1) Are [Start of Phase 1 Date] and [End of Phase 1 Date] actual fields?

2) If they are fields, what is the format of [Start of Phase 1 Date] and [End of Phase 1 Date]  ?

3) Confirm if the fields are stored as Dates and not Text by  trying these expressions in  a text box

= isnum(min([Start of Phase 1 Date] ))   << if returns 0 means that these are stored as Text, if returns -1 then Date

= isnum(min([End of Phase 1 Date] ))     << if returns 0 means that these are stored as Text, if returns -1 then Date

4) if these are Stored as Text format them to Date while loading Data in script as below

     Date#([Start of Phase 1 Date],'CurrentFormatOfTheField') as [Start of Phase 1 Date]

 

 

qlikCommunity1.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Dante_83
Contributor III
Contributor III
Author

Hello Vineeth,

Thank you for your help! I see what my problem is now. I need to format [Start of Phase 1 Date] and [End of Phase 1 Date] to date field. I'm going to work on it this weekend. If it's ok with you, I would like to comeback again just in case I have more questions. Thank you again for your help.