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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Mario_ES
Contributor III
Contributor III

Count if Date

Hello,

I'm trying to create a KPI that counts the total number of orders that have expired.

To do this I have the fields "due date", date and Order Number.

The date format is 'DD/MM/YYYY' for both fields.

So far I have created this formula:

if([Fecha Vencimiento] < max(Fecha)), Count([No. Pedido]))

But I don't get any number.

Can you help me, please!

1 Solution

Accepted Solutions
rubenmarin

Ho Mario, el If debería ir dentro del count:

Count(if([Fecha Vencimiento] < max(Fecha), [No. Pedido]))

Aunque te drá un error de que el max no se puede usar en un count, lo que te obliga a añadir un aggr:

Count(Aggr(if([Fecha Vencimiento] < max(Fecha), [No. Pedido])),[No. Pedido])

O calcular el Max como algo global, no línea a línea, esto se puede hver usando una variable o $-expansion:

Count(if([Fecha Vencimiento] < $(=max(Fecha)), [No. Pedido]))

Y por último tienes la versión con set analysis:

Count({<[Fecha Vencimiento]={"<$(=max(Fecha))"}>} [No. Pedido])

Puede que necesites formatear la fecha:
Count({<[Fecha Vencimiento]={"<$(=Date(max(Fecha)))"}>} [No. Pedido])

View solution in original post

2 Replies
rubenmarin

Ho Mario, el If debería ir dentro del count:

Count(if([Fecha Vencimiento] < max(Fecha), [No. Pedido]))

Aunque te drá un error de que el max no se puede usar en un count, lo que te obliga a añadir un aggr:

Count(Aggr(if([Fecha Vencimiento] < max(Fecha), [No. Pedido])),[No. Pedido])

O calcular el Max como algo global, no línea a línea, esto se puede hver usando una variable o $-expansion:

Count(if([Fecha Vencimiento] < $(=max(Fecha)), [No. Pedido]))

Y por último tienes la versión con set analysis:

Count({<[Fecha Vencimiento]={"<$(=max(Fecha))"}>} [No. Pedido])

Puede que necesites formatear la fecha:
Count({<[Fecha Vencimiento]={"<$(=Date(max(Fecha)))"}>} [No. Pedido])
Mario_ES
Contributor III
Contributor III
Author

Muchas gracias, Rubén!