Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
katherine_mondr
Partner - Contributor
Partner - Contributor

Expression for dates (Expresión para fechas)

Good day!

I have a problem when trying to create an expression of me as a result the total number of kilometers traveled for a day. Citing the following table unit 1 begins his workday with 237 kilometers of bygone days hence to calculate the mileage of the day only 08/02/2015 must subtract 908-237. I wonder how I can perform this subtraction in an expression so that after being captured in a PivotTable.

UnidadFecha/HoraKm recorridos
12/8/2015    10:10 am237
12/8/2015     8:15 pm543
12/8/2015     3:12 pm678
12/8/2015     9:00 pm908

Greetings!

Translated with Google Translate - Qlik Community Administrative Team

Buen día!

Tengo un problema al momento de tratar de crear una expresión que me de como resultado el número total de kilómetros recorridos durante un día. Poniendo como ejemplo la siguiente tabla la unidad 1 comienza su día laboral con 237 kilómetros recorridos de días pasados por lo tanto para poder calcular los kilómetros recorridos únicamente del día 2/8/2015 debo restar 908-237. Quisiera saber como puedo llevar a cabo esta resta en una expresión para que después sea plasmada en una tabla dinámica.

Saludos!

1 Solution

Accepted Solutions
maxgro
MVP
MVP

if you add a field Fecha

LOAD Unidad,

     [Fecha/Hora],

     [Km recorridos],

     subfield([Fecha/Hora], ' ', 1) as Fecha

FROM

[https://community.qlik.com/thread/175095]

(html, codepage is 1252, embedded labels, table is @1);

you can make a chart like this

the expression is

max([Km recorridos]) - min([Km recorridos])

1.png

you can get the same result (without modify the script) in a chart with dimensions

subfield([Fecha/Hora], ' ', 1)

Unidad

expression

max([Km recorridos]) - min([Km recorridos])

View solution in original post

5 Replies
maxgro
MVP
MVP

if you add a field Fecha

LOAD Unidad,

     [Fecha/Hora],

     [Km recorridos],

     subfield([Fecha/Hora], ' ', 1) as Fecha

FROM

[https://community.qlik.com/thread/175095]

(html, codepage is 1252, embedded labels, table is @1);

you can make a chart like this

the expression is

max([Km recorridos]) - min([Km recorridos])

1.png

you can get the same result (without modify the script) in a chart with dimensions

subfield([Fecha/Hora], ' ', 1)

Unidad

expression

max([Km recorridos]) - min([Km recorridos])

katherine_mondr
Partner - Contributor
Partner - Contributor
Author

Thanks a lot Massimo! I will try it!

katherine_mondr
Partner - Contributor
Partner - Contributor
Author

Hi again Massimo!

I have been trying to implement the expression and it works but only for the units that have more than one record. When a unit has only one record then Km Recorridos appear as "-". Do you know what can I do to make the kilometers appear.

maxgro
MVP
MVP

try to uncheck suppress zero values as in image

see attachment

but when you only have 1 record there is no difference (distance)

1.png

katherine_mondr
Partner - Contributor
Partner - Contributor
Author

Thanks! ¿Is there a way to suppress null values?