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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
AnaStone_100
Helper I
Helper I

Help with a measure and filter context

Hi,

I would like some help with a measure for the stacked column chart(on the photo).

This is the case: Measure 1 is working fine, it calculates the sales for last x days according the selection in the date filter (date table).

But Measure 2 is not working correctly, it should calculate the total sales for that whole month but previous year. (not lookin at the last x days).

 

Can you please help.

Thank you.

 

AnaStone_100_0-1649672028434.png

 

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

Hi @AnaStone_100 ,

 

Please try the following formula:

 

Measure2 = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATEADD ( PREVIOUSMONTH ( Dates[Date] ), -11, MONTH )
)

vkkfmsft_0-1649918216637.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

4 REPLIES 4
v-kkf-msft
Community Support
Community Support

Hi @AnaStone_100 ,

 

Please try the following formula:

 

Measure2 = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATEADD ( PREVIOUSMONTH ( Dates[Date] ), -11, MONTH )
)

vkkfmsft_0-1649918216637.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

netanel
Post Prodigy
Post Prodigy

Hey @AnaStone_100 

 

we need mor info about your case

how your Measure looklike?

In the meantime from my understand look at this logic it is supposed to solve the problem

Measure 2 = CALCULATE([Your Total sales],DATEADD('Date'[Date],-1,Year))







Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki

Thanks for the reply,

Well, for Same period last year that is the logic, but as i meantioned I want to exclude the date filter last x days. So using only this DAX is not working:

Measure 2 = CALCULATE([Your Total sales],DATEADD('Date'[Date],-1,Year)) , it doesnt solve the problem.

MyMeasure 1 is more complex beacuse it  takes orders created last x days(slicer) according to the filter and displays values for the sales for each month. 

@AnaStone_100 

If I do not see your formula
It's hard for me to know how to put things together
I would love for picture or the Measure itself

 

If I understand you correctly then

try to put that after the CALCUKATE

KEEPFILTERS( 'Date'[Date] < TODAY() ),
 
and Replace Today in the date that you need to filter
 
 

 








Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors