cancel
Showing results 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

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:

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
Employee

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

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
)
)
)
)```

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]
)
)```

Use a matrix visual to display corresponding fields in Test4.

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.
5 REPLIES 5
Employee

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

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
)
)
)
)```

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]
)
)```

Use a matrix visual to display corresponding fields in Test4.

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.
Helper IV

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

Many Thanks

Helper IV

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

Many Thanks

Helper IV

@v-yulgu-msft

Hi Yuliana,

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

Helper IV
Hello everyone...

Any ideas on this topic ?

Thank you very much!!

Announcements

#### 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 Monthly Update - June 2024

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

#### 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.

#### New forum boards available in Real-Time Intelligence.

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

Top Solution Authors
Top Kudoed Authors