简体   繁体   English

Power BI DAX 从自定义日期获取上个月的值

[英]Power BI DAX to get previous month value from custom date

I have a data which is having FiscalDate information (Fiscalyear starts from July).我有一个包含 FiscalDate 信息的数据(财年从 7 月开始)。 Currently there is a column which shows Revenue, but the Revenue is Fiscal Year to date.目前有一列显示收入,但收入是财政年度至今。 The requirement is to get Current month and previous month revenue.要求是获得当月和上个月的收入。 Since its a custom date, I cannot use the standard date function to get previous month value.由于它是自定义日期,我不能使用标准日期 function 来获取上个月的值。 Could anyone please suggest Dax which can provide me the previous month Revenue.任何人都可以请建议 Dax 可以为我提供上个月的收入。 It should work even if extra filters are added to the report.即使在报告中添加了额外的过滤器,它也应该可以工作。 Given data set enter image description here给定数据集在此处输入图像描述

expected output预计 output

enter image description here在此处输入图像描述

The problem is not very clear.问题不是很清楚。 From my understanding: you need a previous month formula that for the first month of the fiscal year (July) returns 0.据我了解:您需要一个上个月的公式,该公式在财政年度的第一个月(7 月)返回 0。

Solution:解决方案:

Previous Month KPI:=
VAR _FiscalYearFirstMonth = 7
        IF(
           'Calendar'[Month code] = _FiscalYearFirstMonth, 0,
           CALCULATE([MEASURE], PREVIOUSMONTH('Calendar'[Date])
        ) 

If the current month is the beginning of fiscal year (July) then return 0 else compute the previous month.如果当前月份是财政年度的开始(7 月),则返回 0,否则计算上个月。

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

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