获取“第二周”来自Power BI中的日期字段 [英] Get "Week of 2nd" from Date field in power BI
本文介绍了获取“第二周”来自Power BI中的日期字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的DimDate表中有一个日期字段。
I have a date field in my DimDate table.
我想获得另一列 WeekOf
,该列将显示基于星期一的星期数。
例如,我有日期:
I want to get another column WeekOf
that would show the week number based on Monday.
For example I have date:
Date WeekOf
10/2/2017 Week of 2nd
10/9/2017 Week of 9th
10/16/2017 Week of 16th
推荐答案
使用以下公式创建新列将为您提供所需的内容。
Creating a new column with the following formula should give you what you want.
如果每个人都希望将其更改为另一天的一周,请在TargetDate中更改 2
If you every want to change it to be the Week of a different day, change the 2
in the TargetDate variable to which ever day of the week you want.
WeekOf =
VAR TargetDate = DAY(DATEADD(Dates[Date], 2 - WEEKDAY(Dates[Date]), DAY))
VAR TargetDateText = CONCATENATE(TargetDate, SWITCH(TargetDate, 1, "st", 21, "st", 31, "st", 2, "nd", 22, "nd", 3, "rd", 23, "rd", "th"))
RETURN
CONCATENATE("Week of ", TargetDateText)
这篇关于获取“第二周”来自Power BI中的日期字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文