Forum Discussion

powerbiAG's avatar
powerbiAG
Frequent Visitor
3 years ago
Solved

LTM calculation using different reference dates

      Hi All, We have a scenario wherein a corporation has on-boarded other businesses and all the details are available in Subsidiary master  table. Sample data below...    Org Id  Name...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi powerbiAG ,

     

    If you want to calculate the last 12 months Sales Value (Historic) data (for each business) based on the "integration month" in the fact table, I think LTM Value Historic for  Org Id =1 should be 200+120 instead of 100+200+120. Due to Integration Month for Org Id =1 is 2021/Feb, so last 12 month should be from 2020/Feb to 2021/Jan. So 2020/Jan is not in range. 

    Try code as below to create a calculated column.

    LTM Value Historic =
    VAR _Last12months =
        FILTER (
            CALENDARAUTO (),
            [Date]
                <= EOMONTH ( 'Table'[Integration Month], -1 ) + 1
                && [Date]
                    >= EOMONTH ( 'Table'[Integration Month], -13 ) + 1
        )
    RETURN
        CALCULATE (
            SUM ( 'Sales transaction (historic)'[Value (Historic)] ),
            FILTER (
                'Sales transaction (historic)',
                'Sales transaction (historic)'[Month] IN _Last12months
            )
        )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.