Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I need an IF statement where if a specific column has a Date and Hour it would get me the Final Date by checking a separate hour table or a condition that if the Hour is between 00:00:00 and 08:00:00 it would return the previous date.
An example table below shows that ID A to D has an hour between 00:00:00 and 08:00:00 and it must return Date 1 which is reduced by 1 and if the condition is false simply return Date1.
| ID | Date 1 | Hour | Final Date |
| a | 01/05/2020 | 01:00:00 | 01/04/2020 |
| b | 01/05/2020 | 02:00:00 | 01/04/2020 |
| c | 01/05/2020 | 03:00:00 | 01/04/2020 |
| d | 01/05/2020 | 04:00:00 | 01/04/2020 |
| e | 01/05/2020 | 11:00:00 | 01/05/2020 |
The formula i tried to use is
Solved! Go to Solution.
Hi @ggzmorsh
try
Final Time = IF([Hour] < TIME(8,0,0),Date1 - 1,Date1)or
Final Time = IF(TIME(VALUE(LEFT([Hour],2)),00,00) < TIME(8,0,0),Date1 - 1,Date1)
do not hesitate to give a kudo to useful posts and mark solutions as solution
I do not know why my data is always returning the statement true. So the workaround i did is i extracted just the HOUR from the Hour column and used the IF statement on that and it worked.
@ggzmorsh
The issue is possibly cause by unmatched format, please check the format for the date(Date/ Date time) and hour(Time) columns.
Best,
Paul
Hi @ggzmorsh
try
Final Time = IF([Hour] < TIME(8,0,0),Date1 - 1,Date1)or
Final Time = IF(TIME(VALUE(LEFT([Hour],2)),00,00) < TIME(8,0,0),Date1 - 1,Date1)
do not hesitate to give a kudo to useful posts and mark solutions as solution
I forgot to mention this:
Final Time = IF([Hour] < TIME(8,0,0),Date1 - 1,Date1)
When i used this formula earlier it would always return as true.
I used this:
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 64 | |
| 51 | |
| 46 | |
| 23 | |
| 19 |
| User | Count |
|---|---|
| 135 | |
| 110 | |
| 50 | |
| 31 | |
| 29 |