Forum Discussion
How to Compare two date fields?
I want to compare two date fields or set a value in the "Distancia" field when is showing the oldest date field ("Fecha").
I have this:
'Registro Diario' is a table.
A column called "Fecha" and a measure called "Prueba"; "Fecha" comes from a excel file and "Prueba" is calculated as follows
Prueba=CALCULATE ( MIN ( 'Registro Diario'[Fecha] ); ALLSELECTED ( 'Registro Diario' ) )
The Distancia field is calculated as follows:
Distancia (KM) = IF('Registro Diario'[Fecha]='Registro Diario'[Prueba];0;1)
I appreciate your help
Anonymous
Hi, instead of using a calculated column you need to use a measure
D2 = IF ( MIN ( 'Registro Diario'[Fecha] ) = [Prueba]; 0; 1 )
Regards
Victor
Hi Anonymous,
Looking at your PBIX file this as to be change to a measure as I refered in my first post and as Vvelarde also indicates in his response, if you do that it will give you 0 for the first record and 1 for all the others
Regards,
MFelix
8 Replies
- MFelixSuper User
Hi Anonymous,
Is Distancia KM a measure or a column?
Try to change it to this measure:
Distancia (KM) = IF(MAX('Registro Diario'[Fecha])=[Prueba];0;1)Regards,
MFelix
- AnonymousNot applicable
Hi MFelix, thanks for answering
It doesn't work, I shows the following
"Distancia (KM)" is a column of type "Whole number" and format "Decimal Number", "Fecha" is a column of type "Date" and format (d/MM/yyyy), "Prueba" is a measure without type and format (d/MM/yyyy)
- MFelixSuper User
Hi Anonymous,
can you share a sample of the PBIX file?
Regards,
MFelix