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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
WishAskedSooner
Continued Contributor
Continued Contributor

Get Previous Value using Calculate

Hi all,

 

I have a Fact table and several Dimension tables. I currently have the following measure defined in my Data model:

 

 

CALCULATE(SUM('Fact'[Value]), ALL('DimLedger'), 'DimLedger'[ID] = 2)

 

 

I put this measure in a card with a slicer to select the Month from the Date Dimension table. It works as expected.

 

Now, I want to create a second card with a measure that shows the previous month's value based on the selected month in the slicer. I have tried the following, but it just returns a blank:

 

 

CALCULATE(SUM('Fact'[Value]), ALL('DimLedger'), 'DimLedger'[ID] = 2, DATEADD('DimDates'[Date], -1, MONTH))

 

 

I also tried using the ALL() function, but it just returns the selected month value, not the previous month's value:

 

 

CALCULATE(SUM('Fact'[Value]), ALL('DimLedger'), 'DimLedger'[ID] = 2, DATEADD(ALL('DimDates'[Date]), -1, MONTH))

 

 

I am stuck as to what I am doing wrong. Any help is appreciated.

1 ACCEPTED SOLUTION
WishAskedSooner
Continued Contributor
Continued Contributor

I don't know if this is the most elegant solution, but it seems to work. However, if you know of a better solution, please feel free to post.

 

Prev Month Value = 
    VAR PrevMonth = DATEADD('DimDates'[Date], -1, MONTH)
Return
    CALCULATE(SUM('Fact'[Value]), FILTER(ALL('DimLedger'), 'DimLedger'[ID] = 2), FILTER(ALL('DimDates'), 'DimDates'[Date] = PrevMonth))

View solution in original post

2 REPLIES 2
WishAskedSooner
Continued Contributor
Continued Contributor

I don't know if this is the most elegant solution, but it seems to work. However, if you know of a better solution, please feel free to post.

 

Prev Month Value = 
    VAR PrevMonth = DATEADD('DimDates'[Date], -1, MONTH)
Return
    CALCULATE(SUM('Fact'[Value]), FILTER(ALL('DimLedger'), 'DimLedger'[ID] = 2), FILTER(ALL('DimDates'), 'DimDates'[Date] = PrevMonth))
Anonymous
Not applicable

Hi,@WishAskedSooner 


Congratulations on finding a solution to the problem and having already accepted it as a solution, this is very helpful to our community and having community members with the same problem as you will find a solution much faster. Thank you again for your contribution.

 

Best Regards,

Leroy Lu

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors