admin管理员组文章数量:1430515
I want to generate a column. that shows as YTD if the date is the last day of the previous month or before and FCT otherwise.
This Dax code is giving me errors.
First tried Today() and then realised that's not what I want :)
Added Custom" = Table.AddColumn(#"Change Type4","YTD Date", each if [Date.Custom] <= Today() then "YTD" else "FCT")
I want to generate a column. that shows as YTD if the date is the last day of the previous month or before and FCT otherwise.
This Dax code is giving me errors.
First tried Today() and then realised that's not what I want :)
Added Custom" = Table.AddColumn(#"Change Type4","YTD Date", each if [Date.Custom] <= Today() then "YTD" else "FCT")
- The above isn't DAX, it's Power Query. – Sam Nseir Commented Nov 19, 2024 at 15:31
2 Answers
Reset to default 1Try the following:
= Table.AddColumn(#"Changed Type", "YTD Date", each if
DateTime.Date([Date]) <= DateTime.Date(
Date.EndOfMonth(
Date.AddMonths(
DateTime.FixedLocalNow(), -1
)
)
) then "YTD" else "FCT")
- Get current date/time
- Subtract a month
- Get the last date of the month
- Convert both sides to dates
For what it is worth, you can do similar in DAX via EOMONTH
function.
In power query, we don't use today() function to get current date you can try this below function to get current date
= Date.From(DateTime.LocalNow())
then replace the formula with your today() function in your M coding and have a try
enter link description here
本文标签: Dax Add column based on dateStack Overflow
版权声明:本文标题:Dax Add column based on date - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745558323a2663319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论