上月列

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

Column indicating previous month

问题

我创建了一个筛选器,用于筛选上个月的数据,如果我在上个月,那么date_months的值等于"YES",否则值为"NO"。

然后,我想添加一个条件,如果我在每个月的第一天,也就是每个月的01号,我要考虑上个月的数据。

我尝试了以下代码,但它不起作用:

date_Month =
VAR currentrowdate =
    FORMAT ( dimension_calendar[full_date], "mmyyyy" )
VAR month =
    FORMAT ( NOW (), "mmyyyy" )
VAR day =
    FORMAT ( NOW (), "dd" )
VAR last_month = dimension_calendar[actual_date] - 1
RETURN
    IF (
        day = "01",
        IF ( month = last_month, "Yes", "No" ),
        IF ( month = currentrowdate, "Yes", "No" )
    )

你有什么建议吗?谢谢!

英文:

I created a filter that filters me on the last month, if I am in the last month the value da date_months is equal to "YES" otherwise the value is "NO".

date_Month =
VAR currentrowdate =
    FORMAT ( dimension_calendar[full_date], "mmyyyy" )
VAR month =
    FORMAT ( NOW (), "mmyyyy" )
VAR day =
    FORMAT ( NOW (), "dd" )
VAR last_month = dimension_calendar[actual_date] - 1
RETURN
    IF ( month = currentrowdate, "Yes", "No" )

上月列

then I wanted to add a condition that if I am in the first of the month that is to say the 01 of each month I take into account the previous month .

I did this, but it doesn’t work

date_Month =
VAR currentrowdate =
    FORMAT ( dimension_calendar[full_date], "mmyyyy" )
VAR month =
    FORMAT ( NOW (), "mmyyyy" )
VAR day =
    FORMAT ( NOW (), "dd" )
VAR last_month = dimension_calendar[actual_date] - 1
RETURN
    IF (
        day = 01,
        AND ( "No", month = last_month ),
        IF ( month = currentrowdate, "Yes", "No" )
    )

you will have proposals? thank you

I wanted to add a condition that if I am in the first of the month that is to say the 01 of each month I take into account the previous month .

答案1

得分: 0

尝试这个:

以前的月份 =
如果( 月份('表'[日期] -1) = 月份(今天()) - 1, "是", "否")

[![输入图像描述][1]][1]

  [1]: https://i.stack.imgur.com/c636a.png

<details>
<summary>英文:</summary>

Try this one:

Previous Month =
IF( MONTH('Table'[Date] -1) = MONTH(TODAY()) - 1, "YES", "NO")

[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/c636a.png

</details>



huangapple
  • 本文由 发表于 2023年3月10日 01:40:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75688208.html
匿名

发表评论

匿名网友

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

确定