Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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))
Solved! Go to Solution.
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()
)
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?
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
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()
)
User | Count |
---|---|
75 | |
75 | |
45 | |
31 | |
27 |
User | Count |
---|---|
99 | |
89 | |
52 | |
48 | |
46 |