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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Dane
Helper I
Helper I

Token Comma Expected Error

I am trying to add a custom column in a table to calculate the difference between the date when an order is closed against when the order was opened.  Below is my formula.  I am getting a Token Comma Expected Error, when I click the link to show the error it displays where I have marked the "T" red in my DATEDIFF expression.  I am not sure what this error means and why it would display on a single letter in my expression.  

 

IF(Orders[[ClosedDate]>0,DATEDIFF(Orders[ClosedDate],Orders[Date],DAY),DATEDIFF(TODAY(),Orders[Date],DAY))

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @Dane ,

 

right after the if you have 2 brackets Orders[[ClosedDate].

Can you try to remove one of them?:

New Column =
IF(
    Orders[ClosedDate] > 0,
    DATEDIFF(
        Orders[ClosedDate],
        Orders[Date],
        DAY
    ),
    DATEDIFF(
        TODAY(),
        Orders[Date],
        DAY
    )
)

 

As you just want to get days you can also just subtract the the dates:

New Column =
IF(
    Orders[ClosedDate] > 0,
        Orders[Date] - Orders[ClosedDate],
        Orders[Date] - TODAY()
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

View solution in original post

3 REPLIES 3
Dane
Helper I
Helper I

Thanks for the quick reply.  I subtracted the dates from each other as you specified in your example, there were no syntax errors, I deployed the change and am getting the error message below saying the name "IF" was not recognized, its asking me to make sure it was spelled correctly, do you know what may be causing this?

 

Dane_0-1633095973061.png

 

Hey @Dane ,

 

seems like you put the Power Query formula (M language) in the Power BI calculated column (DAX language).

Just copy the formula I posted in the last answer  as calculated column. That should do it.

 

Best regards

Denis

selimovd
Super User
Super User

Hey @Dane ,

 

right after the if you have 2 brackets Orders[[ClosedDate].

Can you try to remove one of them?:

New Column =
IF(
    Orders[ClosedDate] > 0,
    DATEDIFF(
        Orders[ClosedDate],
        Orders[Date],
        DAY
    ),
    DATEDIFF(
        TODAY(),
        Orders[Date],
        DAY
    )
)

 

As you just want to get days you can also just subtract the the dates:

New Column =
IF(
    Orders[ClosedDate] > 0,
        Orders[Date] - Orders[ClosedDate],
        Orders[Date] - TODAY()
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.