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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Get the last value returns to blank

Hello, Looking for your best codes.
I wanted to get the previous month actual volume but it returns all blanks.
Please check my codes.

Denski11_0-1602659717551.png

 

1 ACCEPTED SOLUTION

@Anonymous  please try this code in a calculated column

=CALCULATE(SUM(Table3[Actual Volume]),ALLEXCEPT(Table3,Table3[Segment],Table3[Sub-Segment]),PREVIOUSMONTH(Table3[Month]))

 

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , do you need a measure you can do this wauth date table, like given example

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
this month =MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH('Date'[Date])))
last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value = CALCULATE(sum(''Table''[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
wdx223_Daniel
Super User
Super User

PREVIOUSMONTH return a table, not a scalar value, so it can not be compared with a date value.

Anonymous
Not applicable

@wdx223_Daniel  thanks for that, do have any solution on this codes. I wanted to show the previous month of actual volume.
Thanks for your support

@Anonymous  please try this code in a calculated column

=CALCULATE(SUM(Table3[Actual Volume]),ALLEXCEPT(Table3,Table3[Segment],Table3[Sub-Segment]),PREVIOUSMONTH(Table3[Month]))

 

Anonymous
Not applicable

@wdx223_Daniel  thanks bro you made it. 🙂

By The way when we use allexcept that means it will not include or filter the sub-seg and segment ?

@Anonymous ALLEXCEPT means remove all filters on the table except the columns listed.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.