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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors