Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Solved! Go to Solution.
@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
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @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
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @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)
Hi @Anonymous,
can you share a sample of the PBIX file?
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @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
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português
I apologize because I said something wrong, in fact the distance field that I have as a column is because I need to perform the following calculation
Distancia (KM)= var Lat1='Registro Diario'[Latitud - Distancia] * 3,1415 / 180
var Lat2 = 'Registro Diario'[Latitud - Distancia.Anterior] * 3,1415 / 180
var Lon1 = 'Registro Diario'[Longitud - Distancia] * 3,1415 / 180
var Lon2 = 'Registro Diario'[Longitud - Distancia.Anterior] * 3,1415 / 180
var valor = Cos( Lat1 ) * Cos( Lat2 ) * Cos( Lon2 - Lon1 ) + Sin( Lat1 ) * Sin( Lat2 )
return IF(valor<0,99999999999999999999;IF('Registro Diario'[Fecha]=CALCULATE ( MIN ( 'Registro Diario'[Fecha] ); ALLSELECTED ( 'Registro Diario' ) );0;6378*ACOS(valor));0)
When I try to pass it as a measure this columns weren't recognized
'Registro Diario'[Longitud - Distancia.Anterior]
'Registro Diario'[Longitud - Distancia]
'Registro Diario'[Latitud - Distancia.Anterior]
'Registro Diario'[Latitud - Distancia]
I apologize for the lack of information
Hi @Anonymous,
Try to use a MAX or MIN function on those columns to make context on them.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |