Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
@ links to members, content
I am new to Power Query. I tried to add this column I am getting error message "Token Literal expected". Here is my DAX in power query
= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] > Date.From(DateTime.LocalNow()) & if [Calibration Due] < Date.From(DateTime.LocalNow()+ 90 then "Due in 90 Days" else if [Calibration Due] > Date.From(DateTime.LocalNow()) then |
"In Calibration" else "OverDue")
My two condition is not being evaluated. The results only returns "OverDue"
Solved! Go to Solution.
Use this please
= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] <= Date.From(DateTime.LocalNow()) then "Overdue" else if [Calibration Due] <= Date.From(Date.AddDays(DateTime.LocalNow(),90)) then "Due in 90 Days"
else "In Calibration")
you think you should use "and" instead of "&"?
or you should use "or" instead of "&".
Try to play with these until you get your desired result.
If you need more help,
provide a sample data.
Thanks
the issue is the formula is not reading the first condition I do have some rows that meet that first condition. I am having trouble adding 90 days to the Date.AddDays(DateTime.LocalNow(),90). I am getting error message "Token Literal Expected"
= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] > Date.From(DateTime.LocalNow()) and if [Calibration Due] < Date.AddDays(DateTime.LocalNow(),90) then "Due in 90 Days" else if [Calibration Due] > Date.From(DateTime.LocalNow()) then
"In Calibration" else "OverDue")
Use below formula
= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] <= Date.From(DateTime.LocalNow()) then "In Calibration" else if [Calibration Due] <= Date.From(Date.AddDays(DateTime.LocalNow(),90)) then "Due in 90 Days"
else "Overdue")
Thank you for adjusting the formula, it is returning the expected text string but applying color coding to wrong columns. Where it is saying "In Calibration" it should have "OverDue" and where it is "In Calibration" it should say "OverDue".
This is my color measure
I really appreciate your help on this. Getting close to the expected solution.
Use this please
= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] <= Date.From(DateTime.LocalNow()) then "Overdue" else if [Calibration Due] <= Date.From(Date.AddDays(DateTime.LocalNow(),90)) then "Due in 90 Days"
else "In Calibration")
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 6 | |
| 5 |