PowerBi – 本周

huangapple go评论49阅读模式
英文:

PowerBi - Current Week

问题

我有一个多行卡片,显示我们的仓库今天打包了多少个“CLL、PLL和KG”。

然而,我想要一个类似的卡片,总结当前的这一周。
(作为我们仓库的有趣信息)
但是我在创建筛选条件,使其仅显示当前周的部分遇到了困难。

我用于获取“今天”的筛选条件相当基本(不太漂亮,但能用)

Gettoday = IF('Date'[Date]=TODAY(),"是","否")

我尝试用周来创建类似的筛选条件,但似乎不起作用。

有人有什么建议吗?

谢谢!

英文:

I have a Multi-row card where it shows how many CLL, PLL, and KG our warehouse have packed "today".

However I would like to have similar card which sums up the current week.
(Meant as a fun fact for our warehouse)
But i'm struggling with making a filter from where it only shows the current week.

The filter I made to get "today" is pretty basic (not pretty, but it works)

Gettoday = IF('Date'[Date]=TODAY(),"Yes","No")

I have tried making similar with week instead but it don't seem to work.

Anyone have any suggestions?

Thanks

答案1

得分: 1

你可以这样调整你的方法(假设你在这里使用的是一个计算列):

get_current_week = IF(
    AND(
    WEEKNUM(TODAY()) = WEEKNUM('Date'[Date]),
    YEAR(TODAY()) = YEAR('Date'[Date])
    ),
    "是",
    "否"
)

基本上,你比较了今天的年份和周数与你的日期数值的年份和周数:
https://learn.microsoft.com/en-us/dax/weeknum-function-dax

我建议你查看一下微软的日期函数参考,因为肯定有一种更优雅的方法来设置这个筛选条件。

英文:

what you can do, to fit your approach (assuming you're using a calculated column here) would be something like:

get_current_week = IF(
    AND(
    WEEKNUM(TODAY()) = WEEKNUM('Date'[Date]),
    YEAR(TODAY()) = YEAR('Date'[Date])
    ),
    "Yes",
    "No"
)

basically you compare year & weeknum of today, to your date value's:
https://learn.microsoft.com/en-us/dax/weeknum-function-dax

i would recommend, that you check out the microsoft reference on datefunctions because there's bound to be a more elegant way to setting that filter.

huangapple
  • 本文由 发表于 2023年6月15日 16:23:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480513.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定