Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Ivolution93
Frequent Visitor

DAX If statement help

I am wanting it to give me the result of a date minus one day if it is before 6:30 in the morning else use just the result of a date.

 

DateShiftStarted =
if (WBoxCountTransactions[TimePoint] < "06:30:00",
    WBoxCountTransactions[Date Box Created] - 1,
   WBoxCountTransactions[Date Box Created]
    )
 
i am however getting the following message
DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.
 
I have checked both columns used in the dax and one is TIME and another is DATE i dont have a value of text
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ivolution93 

try like

if (WBoxCountTransactions[TimePoint] < time(06,30,00) ,
WBoxCountTransactions[Date Box Created] - 1,
WBoxCountTransactions[Date Box Created]
)

 

or

 

if (WBoxCountTransactions[TimePoint].time < time(06,30,00) ,
WBoxCountTransactions[Date Box Created] - 1,
WBoxCountTransactions[Date Box Created]
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Ivolution93 ,

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

Anonymous
Not applicable

Hi @Ivolution93 ,

According to my understanding, you want to calculate the Date based on Time  , right?

You could use TIMEVALUE() to compare time ,like the following formula:

Column =
IF (
    WBoxCountTransactions[TimePoint] < TIMEVALUE ( "6:30 AM" ),
    WBoxCountTransactions[Date Box Created].[Date] - 1,
    WBoxCountTransactions[Date Box Created]
)

My visualization looks like this:

8.31.2.1.PNG

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

mahoneypat
Microsoft Employee
Microsoft Employee

If this is for a calculated column, you can use the TIME function instead of putting the time in quotes.

 

DateShiftStarted =
if (WBoxCountTransactions[TimePoint] < TIME(6,30,0),
    WBoxCountTransactions[Date Box Created] - 1,
   WBoxCountTransactions[Date Box Created]
    )
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


amitchandak
Super User
Super User

@Ivolution93 

try like

if (WBoxCountTransactions[TimePoint] < time(06,30,00) ,
WBoxCountTransactions[Date Box Created] - 1,
WBoxCountTransactions[Date Box Created]
)

 

or

 

if (WBoxCountTransactions[TimePoint].time < time(06,30,00) ,
WBoxCountTransactions[Date Box Created] - 1,
WBoxCountTransactions[Date Box Created]
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors