[英]Before previous month measure in (DAX) Power BI
I am struggling with DAX measure to get 2nd month from today, or in business terms, before previous month (so lets say May from now).我正在努力使用 DAX 措施来获得从今天开始的第 2 个月,或者在业务方面,在上个月之前(所以从现在开始说是 5 月)。
I am using this DAX:我正在使用这个 DAX:
Prev-2Months =
CALCULATE (
CALCULATE (
[Comp_Spend],
MONTH ( CCC[Date] )
= IF (
MONTH ( MAX ( CCC[Date] ) ) <= 2,
10 + MONTH ( MAX ( CCC[Date] ) ), // similar DAX is for Month
before (so June) with a
little tweak
MONTH ( MAX ( CCC[Date] ) ) - 2
),
YEAR ( CCC[Date] )
= IF (
MONTH ( MAX ( CCC[Date] ) ) <= 2,
YEAR ( MAX ( CCC[Date] ) - 1 ),
YEAR ( MAX ( CCC[Date] ) )
),
ALL ( V_Dim_Dates ),
KEEPFILTERS ( CCC[ClinicID] )
)
)
When it comes to February 2022 with slicer I am getting Blank values, assuming that Fiscal Year ends on 09/30.当谈到 2022 年 2 月的切片器时,我得到的是空白值,假设财政年度在 09/30 结束。 How can I solve this to not getting blanks for this "year transition" case?
我该如何解决这个问题,以免这个“年过渡”案例出现空白?
Hmmm I guess I solved it using DATEADD, where my huge formula gives the same result.. :/嗯,我想我使用 DATEADD 解决了它,我的巨大公式给出了相同的结果..:/
Prev-1M = CALCULATE ([Compliance_Spend],DATEADD(Commercial[Date],-1,MONTH),REMOVEFILTERS(V_Dim_Dates_Extended))
So I can easily adjust if I wanna 1 or 2 or 3 months to have as previous..因此,如果我想像以前一样拥有 1 或 2 或 3 个月,我可以轻松调整。
It is good to know that there are XYZ options in DAX how you can obtain the same thing.很高兴知道 DAX 中有 XYZ 选项如何获得相同的东西。
Credits for suggesting: @Anonymous建议的学分:@Anonymous
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.