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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bml123
Post Patron
Post Patron

Get value from previous month for each id

Hi,

 

I have a table like this

 

IdAmountDateInserted
12031/03/2022
11030/04/2022
25030/04/2022
22031/03/2022
33030/04/2022
34031/03/2022

 

and a slicer for the dateinserted. 

When I chose Apr-2022, it should show data like this

 

IdCurrent AmountPrevious Amount
11020
25020
33040

 

How do I achieve this?

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @bml123 ,

 

You can use this function PREVIOUSMONTH to get the data.

Please refer the following expression:

Previous Amount =
CALCULATE (
    SUM ( Amount[Amount] ),
    ALLEXCEPT ( Amount, Amount[Id] ),
    PREVIOUSMONTH ( Amount[DateInserted] )
)

 

The expression provided by@Anonymous works fine too, however, it maybe some mistake when the table has two years data.

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @bml123 ,

 

You can use this function PREVIOUSMONTH to get the data.

Please refer the following expression:

Previous Amount =
CALCULATE (
    SUM ( Amount[Amount] ),
    ALLEXCEPT ( Amount, Amount[Id] ),
    PREVIOUSMONTH ( Amount[DateInserted] )
)

 

The expression provided by@Anonymous works fine too, however, it maybe some mistake when the table has two years data.

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

Anonymous
Not applicable

Hi @bml123 

You can use this measure

 

Previous Amount =
CALCULATE (
SUM ( Amount[Amount] ),
MONTH ( Amount[DateInserted] )
= MONTH (
SELECTEDVALUE ( Amount[DateInserted] )
) - 1
)

 

Here's what i got

 

esha_shah2002_0-1653652435873.png

 

if this post helps, Accept it as a solution

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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