如何在DAX中获取上个月的值,不包括周末。

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

How to get values from last month excluding weekends in DAX

问题

以下是已翻译的内容:

下面的DAX表达式通过扫描表格(VW_RisOrderTable)中的所有日期,提供了一个值。

MAXX(
    VALUES(VW_RisOrderTable[OrderDate].[Date]),
    CALCULATE(DISTINCTCOUNT(VW_RisOrderTable[AccessionNo]))
    )

我只想要上个月的值,而且要排除周末(星期六和星期日)。
我尝试过使用Parellelperiod,但未获得结果。

英文:

The DAX expression below gives the value by scanning all the dates from the table (VW_RisOrderTable).

MAXX(
    VALUES(VW_RisOrderTable[OrderDate].[Date]),
    CALCULATE(DISTINCTCOUNT(VW_RisOrderTable[AccessionNo]))
    )

I want the value from the last month only and weekends (Saturday & Sunday) should be excluded.
I have tried using Parellelperiod but couldn't get the result.

答案1

得分: 1

你的问题不完整,但如果我理解了你的意思,你可以尝试在日期表中创建一个新的列。

工作日 = 
   VAR 是周末 = Dates[Number Day] IN {6,7}
   RETURN
      IF (是周末, 0, 1)

这将允许你创建一个用于筛选日期的度量。例如:

CALCULATE(DISTINCTCOUNT(VW_RisOrderTable[AccessionNo]), Dates[工作日] <> 0)

我没有完全列出你的公式,但你可以根据需要进行其余部分的补充。如果你想要另一个视角,请改进你的问题。

英文:

Your question is incomplete but.... If I understood your idea.... you can try creating a new column in your date table.

Laboral Day = 
   VAR IsWeekend = Dates[Number Day] IN {6,7}
   

RETURN

   IF (IsWeekend,0,1)

This allow you to create a measure filtering days
For example:

CALCULATE(DISTINCTCOUNT(VW_RisOrderTable[AccessionNo]), Dates[Laboral Day]&lt;&gt;0)

I haven't put all your formula but you can realize the rest...
If you want another point of view please improve your question.

huangapple
  • 本文由 发表于 2023年3月1日 13:33:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75599917.html
匿名

发表评论

匿名网友

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

确定