简体   繁体   English

根据 Power BI 中的本地日期添加月份的最后日期列

[英]Add last date column of the month based on local date in power BI

I want to add the column of the last working day of the month (in this case, I want to create the column last date highlighted in yellow bellow).我想添加该月最后一个工作日的列(在这种情况下,我想创建以黄色波纹管突出显示的最后日期列)。 Because the holiday schedule of each country is different, so it is not possible to use the formula to exclude Sunday.因为每个国家的节假日安排不同,所以不能用公式排除周日。

For example in the image below me, my last day of April is 28-Apr-2023 (Not 30-April-2023), the function EOMONTH(Data[Date], 0 ) can't use in this case too.例如在我下面的图片中,我四月的最后一天是2023 年 4 月 28 日(不是 2023 年 4 月 30 日),function EOMONTH(Data[Date], 0 )也不能在这种情况下使用。 Similar to May...类似五月...

在此处输入图像描述

Does anyone have any solution please help me?有没有人有任何解决方案请帮助我?

It's hard to give an exact answer without seeing your data structure, but the basic idea is to perform a LASTDATE() calculation filtered to exclude non-business days.如果不查看您的数据结构,很难给出准确的答案,但基本思想是执行过滤后的 LASTDATE() 计算以排除非工作日。 This assumes you have a 'Calendar'[EOMONTH]' column ( EOMONTH('Calendar'[Date],0) ).这假设您有一个'Calendar'[EOMONTH]'列 ( EOMONTH('Calendar'[Date],0) )。

CALCULATE(
    LASTDATE( 'Calendar'[Date] ),
    ALLEXCEPT( 'Calendar', 'Calendar'[EOMONTH] ),
    WEEKDAY('Calendar'[Date],3) < 5
)

This assumes a standard weekend of Saturday/Sunday.这假设周六/周日是标准周末。 To change that by locale, you would need a weekend fact table related to the Calendar dimension and a locale dimension.要按语言环境更改它,您需要一个与日历维度和语言环境维度相关的周末事实表。 You would need the same structure to have a locale-specific holiday schema.您将需要相同的结构来拥有特定于语言环境的假期模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM