年初至今Powerbi方差-会计年度

时间:2018-09-28 14:39:09

标签: powerbi dax powerquery powerbi-embedded powerbi-desktop

我无法按国家/地区计算财务差异,因此无法复制每个国家/地区的总价值。

6月至5月的我的测量和会计年度

YTD Budget =
CALCULATE (
    SUM ( 'Data'[Expenses] );
    AND (
        Data[Period]
            >= IF ( MONTH (TODAY()) >= 6; MONTH (TODAY()) - 5; MONTH (TODAY ()) + 3 )
                - 4;
        Data[Period]
            <= IF ( MONTH (TODAY()) >= 6; MONTH (TODAY()) - 5; MONTH (TODAY ()) + 3 )
                - 1
    );
    Data[Scenario] = "Budget";
    ALLEXCEPT ( DATA; Data[Scenario] )
)

YTD Actual =
CALCULATE (
    SUM ( 'Data'[Expenses] );
    AND (
        Data[Period]
            >= IF ( MONTH (TODAY()) >= 6; MONTH (TODAY()) - 5; MONTH (TODAY ()) + 3 )
                - 4;
        Data[Period]
            <= IF ( MONTH (TODAY()) >= 6; MONTH (TODAY()) - 5; MONTH (TODAY ()) + 3 )
                - 1
    );
    Data[Scenario] = "Actual";
    ALLEXCEPT ( DATA; Data[Scenario] )
)

YTD Var = [YTD Budget] - [YTD Actual] = 1,307

YTD Var % =
IF (
    [YTD Budget] = 0,
    0,
    ( [YTD Budget] - [YTD Actual] )
        / ABS ( [YTD Budget] )
)

我的数据集

Department Country Class Scenario Month Fiscal Year Expenses

HR Chile Salary Actual Jun FY-2018 8837
HR Chile Salary Actual Jul FY-2018 6288
HR Chile Salary Actual Aug FY-2018 6096
HR Colombia Salary Actual Jun FY-2018 6187
HR Colombia Salary Actual Jul FY-2018 6547
HR Colombia Salary Actual Aug FY-2018 7613
HR Chile Salary Budget Jun FY-2018 6062
HR Chile Salary Budget Jul FY-2018 7491
HR Chile Salary Budget Aug FY-2018 6689
HR Colombia Salary Budget Jun FY-2018 7191
HR Colombia Salary Budget Jul FY-2018 8466
HR Colombia Salary Budget Aug FY-2018 6976

YTD- Actual: 41,568.00 
YTD- Budget: 42,875.00

预期结果:

Country     Var($)          Var%
Chile       -979 
Colombia    2,286

1 个答案:

答案 0 :(得分:1)

如果您在ALLEXCEPT过滤器的Data [Country]中添加YTD实际和YTD预算,则YTD Var将获得您期望的值:

YTD Actual2 = 
CALCULATE (
    SUM ( 'Data'[Expenses] );
    AND (
        Data[Period]
            >= IF ( MONTH (TODAY()) >= 6; MONTH (TODAY()) - 5; MONTH (TODAY ()) + 3 )
                - 4;
        Data[Period]
            <= IF ( MONTH (TODAY()) >= 6; MONTH (TODAY()) - 5; MONTH (TODAY ()) + 3 )
                - 1
    );
    Data[Scenario] = "Actual";
    ALLEXCEPT ( DATA; Data[Scenario];Data[Country] )
)

您还可以添加新的计算列以按国家/地区获取YTD Var的值:

YTD Var = Calculate (sum(Data[YTD Budget2]))-Calculate (sum(Data[YTD Actual2]))

enter image description here

您需要这个结果吗?