Forum Discussion
How can i compare 2 tables(2 columns from different tables) using Date and/or Hour?
- 6 years ago
Hi Anonymous ,
Sorry for late back. I find that you create a new thread and give a sample. So I modify the formula based on your pbix file.
For your sample, I think "Tempo" and "DataInicial" are date type. And you want them to be time type. You could use the function of TIMEVALUE to get the time values.
Start time = TIMEVALUE(tabela2[DataInicial]) End Time = tabela2[Start time] + tabela2[Horas (h)] Time = TIMEVALUE(tabela1[Tempo])And then create a measure to get the Velocidade values.
Note : There is no relationships between the tables.
Measure = IF ( MAX ( tabela1[Time] ) >= MAX ( tabela2[Start time] ) && MAX ( tabela1[Time] ) <= MAX ( tabela2[End Time] ), MAX ( tabela1[Velocidade(km/h)] ), BLANK () )Please reference this blog to learn more about measure and calculated column.
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
Sorry for late back. I find that you create a new thread and give a sample. So I modify the formula based on your pbix file.
For your sample, I think "Tempo" and "DataInicial" are date type. And you want them to be time type. You could use the function of TIMEVALUE to get the time values.
Start time = TIMEVALUE(tabela2[DataInicial])
End Time = tabela2[Start time] + tabela2[Horas (h)]
Time = TIMEVALUE(tabela1[Tempo])
And then create a measure to get the Velocidade values.
Note : There is no relationships between the tables.
Measure =
IF (
MAX ( tabela1[Time] ) >= MAX ( tabela2[Start time] )
&& MAX ( tabela1[Time] ) <= MAX ( tabela2[End Time] ),
MAX ( tabela1[Velocidade(km/h)] ),
BLANK ()
)
Please reference this blog to learn more about measure and calculated column.
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks v-xuding-msft for your help.
I wrote one formula that repport me and InitialDate and EndDate for each row, including the exactly Time(Tempo in my table) in a range (InitialDate and EndDate).
This is the formula:
- v-xuding-msft6 years ago
Community Support
Hi Anonymous ,
Hope that your report will run smoothly. If you have any questions, please feel free to ask us.
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.