Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
alexbalazsalex
Helper IV
Helper IV

last month amount - previous month amount

Hi All,

 

Amount last month vs previous month.

 

Dear all i would need your support again:

 

I would need a measure which calculates last month amount (updates each month a new column is avaialble) - previous month amount:

 

asasaasf.PNG

 

in this case amount of 12/1/2017 - amount of 12/1/2017

 

if i have an update for 01/01/2018 than amount of 01/01/2018- amount of 12/01/2017..

 

is it possible ?

 

Many Thanks

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @alexbalazsalex,

 

Please unpivot table structure in Query Editor mode to get below structure.

1.PNG

 

Then, create a calculated column to get the difference of amount between last month and previous month

Amount last month vs previous month =
CALCULATE (
    SUM ( Test3[Value] ),
    FILTER (
        ALLEXCEPT ( Test3, Test3[Category] ),
        IF (
            MONTH ( TODAY () ) = 1,
            Test3[Date].[Year]
                = YEAR ( TODAY () ) - 1
                && Test3[Date].[MonthNo] = 12,
            Test3[Date].[MonthNo]
                = MONTH ( TODAY () ) - 1
        )
    )
)
    - CALCULATE (
        SUM ( Test3[Value] ),
        FILTER (
            ALLEXCEPT ( Test3, Test3[Category] ),
            IF (
                MONTH ( TODAY () ) = 1,
                Test3[Date].[Year]
                    = YEAR ( TODAY () ) - 1
                    && Test3[Date].[MonthNo] = 11,
                IF (
                    MONTH ( TODAY () ) = 2,
                    Test3[Date].[Year]
                        = YEAR ( TODAY () ) - 1
                        && Test3[Date].[MonthNo] = 12,
                    Test3[Date].[MonthNo]
                        = MONTH ( TODAY () ) - 2
                )
            )
        )
    )

2.PNG

 

Based on above table, create a new table.

Test4 =
UNION (
    SELECTCOLUMNS (
        Test3,
        "Category", Test3[Category],
        "Date", Test3[Date],
        "Amount", Test3[Value]
    ),
    SELECTCOLUMNS (
        SUMMARIZE (
            Test3,
            Test3[Category],
            "Diff", AVERAGE ( Test3[Amount last month vs previous month] )
        ),
        "Category", [Category],
        "Date", "Amount last month vs previous month",
        "Amount", [Diff]
    )
)

3.PNG

 

Use a matrix visual to display corresponding fields in Test4.

4.PNG

 

Each month the source data is updated, when you refresh the report page manually, the data displayed on visual will be updated, too.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yulgu-msft
Employee
Employee

Hi @alexbalazsalex,

 

Please unpivot table structure in Query Editor mode to get below structure.

1.PNG

 

Then, create a calculated column to get the difference of amount between last month and previous month

Amount last month vs previous month =
CALCULATE (
    SUM ( Test3[Value] ),
    FILTER (
        ALLEXCEPT ( Test3, Test3[Category] ),
        IF (
            MONTH ( TODAY () ) = 1,
            Test3[Date].[Year]
                = YEAR ( TODAY () ) - 1
                && Test3[Date].[MonthNo] = 12,
            Test3[Date].[MonthNo]
                = MONTH ( TODAY () ) - 1
        )
    )
)
    - CALCULATE (
        SUM ( Test3[Value] ),
        FILTER (
            ALLEXCEPT ( Test3, Test3[Category] ),
            IF (
                MONTH ( TODAY () ) = 1,
                Test3[Date].[Year]
                    = YEAR ( TODAY () ) - 1
                    && Test3[Date].[MonthNo] = 11,
                IF (
                    MONTH ( TODAY () ) = 2,
                    Test3[Date].[Year]
                        = YEAR ( TODAY () ) - 1
                        && Test3[Date].[MonthNo] = 12,
                    Test3[Date].[MonthNo]
                        = MONTH ( TODAY () ) - 2
                )
            )
        )
    )

2.PNG

 

Based on above table, create a new table.

Test4 =
UNION (
    SELECTCOLUMNS (
        Test3,
        "Category", Test3[Category],
        "Date", Test3[Date],
        "Amount", Test3[Value]
    ),
    SELECTCOLUMNS (
        SUMMARIZE (
            Test3,
            Test3[Category],
            "Diff", AVERAGE ( Test3[Amount last month vs previous month] )
        ),
        "Category", [Category],
        "Date", "Amount last month vs previous month",
        "Amount", [Diff]
    )
)

3.PNG

 

Use a matrix visual to display corresponding fields in Test4.

4.PNG

 

Each month the source data is updated, when you refresh the report page manually, the data displayed on visual will be updated, too.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yulgu-msft,

 

Can you share the power bi file you created to show this result ?

 

Many Thanks

Hi @v-yulgu-msft,

 

Can you share the power bi file you created to show this result ?

 

Many Thanks

@v-yulgu-msft

 

Hi Yuliana,

 

Please upload the pbix .. as i can not figur eout how it works

alexbalazsalex
Helper IV
Helper IV

Hello everyone...


Any ideas on this topic ?

Thank you very much!!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.