Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello,
I currently have a report that essentially takes two values [Year Day No] and [Today Year Number]
[Year Day No] is the year and day number merged of the ending date of a production order
[Today Year Number] is the year and day number of today's date merged.
My current calculation can be seen below which is wrong.
Essentially I was using this to get my "Daily State" outcome, the problem is of course when the end date of a production order is in 2025 and in the beginning of the year the [year day number] will be smaller than the [today year number] thus resulting in a "Late" when it really is not. Example below.
I know this is probably very confusing, but I need to find a way to re-calculate this so that my "Daily State" is correct.
Any help would be much appreciated!
Thanks
Jeremy
Solved! Go to Solution.
don't use an awkward [Year Day No] - use an awkward "Days since 12/30/1899" number which you get when you convert your date column to "Whole Number" . That also works across year boundaries.
Hi,
Thanks for the solution @lbendlin provided, and i want to offer some more information for user to refer to.
hello @Grimfandango227 , based on your desscrition, you don't need to conver the date the whole number, you can change your code to the following.
=Table.AddColumn(#"Changed Type1", "Daily State", each let _today=DateTime.Date(DateTime.LocalNow()),
_7today=Date.AddDays(_today,-7),
_13today=Date.AddDays(_today,+13),
_format=Number.ToText(Date.Month([Ending_date]))&Number.ToText(Date.Day([Ending_date]))
in if [Ending_date]<_7today then "Late" else if [Ending_date]>_13today then "Future" else if [Ending_date]=_today then "Today" else _format)
Output
And you can refer to the attachments.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for the solution @lbendlin provided, and i want to offer some more information for user to refer to.
hello @Grimfandango227 , based on your desscrition, you don't need to conver the date the whole number, you can change your code to the following.
=Table.AddColumn(#"Changed Type1", "Daily State", each let _today=DateTime.Date(DateTime.LocalNow()),
_7today=Date.AddDays(_today,-7),
_13today=Date.AddDays(_today,+13),
_format=Number.ToText(Date.Month([Ending_date]))&Number.ToText(Date.Day([Ending_date]))
in if [Ending_date]<_7today then "Late" else if [Ending_date]>_13today then "Future" else if [Ending_date]=_today then "Today" else _format)
Output
And you can refer to the attachments.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
don't use an awkward [Year Day No] - use an awkward "Days since 12/30/1899" number which you get when you convert your date column to "Whole Number" . That also works across year boundaries.
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 |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 5 | |
| 5 | |
| 5 |