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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jitmondo
Helper III
Helper III

Exclude anything before current month in dax measure used in stacked bar/line chart

Hi All,

 

I have a measure to calculate one of the bars in my chart, I am trying to exclude date in this category in a way that whenever you look at it regardless of data it will exclude data from the current month.

 

I have used 

To Date Cover = (CALCULATE([Cover],DATEADD(Dates[Date],-1,MONTH)))
 
which gives me
 
Jitmondo_0-1644316029727.png

this kinda behaves as expected since we are in feb it is taking away values for january, is there a way to write this so its dynamic as when we move to march it will exclude feb but january will still show. I want anything before the current month to be excluded.

I was planning to use this dax and tweak to take out the negatives in the chart too but fear this is not quite right.

 

any advice on this or tips on what I could do ?

 

thanks

 

1 ACCEPTED SOLUTION

@Jitmondo , Try on of the two

 


CALCULATE(CALCULATE([Cover],DATEADD(Dates[Date],-1,MONTH)), Filter(Dates, Dates[Date]<=eomonth(today() ,-2)))

 

or

if(max(Dates[Date]) <= <=eomonth(today() ,-2), CALCULATE([Cover],DATEADD(Dates[Date],-1,MONTH)), blank())

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

View solution in original post

7 REPLIES 7
Jitmondo
Helper III
Helper III

resolved by using today function - however will have to see what happens when we hit March !

Jitmondo
Helper III
Helper III

still at a loss, and I cant really breakdown this data to send right now.

 

I think I need a way to calculate this running total but say I only want to see a running total from current month onwards but as it is cumulative the value from previous months should roll over...

 

I saw a previous post you commented on that touched on this but I cant get it to work right

https://community.powerbi.com/t5/Desktop/Running-total-future-months-only/td-p/1172594

 

 

 

amitchandak
Super User
Super User

@Jitmondo , Try like

 

To Date Cover = (CALCULATE([Cover],DATEADD(Dates[Date],-1,MONTH), Dates[Date]<=eomonth(today() ,-2)))

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

Thanks Amit that takes away all of the light blue (to date cover) away...

 

Jitmondo_0-1644316503127.png

 

@Jitmondo , Try on of the two

 


CALCULATE(CALCULATE([Cover],DATEADD(Dates[Date],-1,MONTH)), Filter(Dates, Dates[Date]<=eomonth(today() ,-2)))

 

or

if(max(Dates[Date]) <= <=eomonth(today() ,-2), CALCULATE([Cover],DATEADD(Dates[Date],-1,MONTH)), blank())

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Will put something together- could it not be working because the cover measure is cumulative maybe ?

because I am using the below 2 measures to calculate the cover measure as

 

Cover = (CALCULATE(([Month Target (cumulative)] * 2 )-[Cum_Open_Weighted_Pipeline]))
 
which is broken down as 
 
1
Month Target (cumulative) = CALCULATE(SUMX('Sales Targets','Sales Targets'[Target GBP]), FILTER(ALL('Dates'),'Dates'[Date]<=MAX('Dates'[Date]) && (YEAR('Dates'[Date])>=YEAR(TODAY()))))  
 
 
2
Cum_Weighted_Pipeline = CALCULATE(SUMX('Opportunity','Opportunity'[Weighted Pipeline]), FILTER(ALL('Dates'),'Dates'[Date]<=MAX('Dates'[Date]) && (YEAR('Dates'[Date])>=YEAR(TODAY()))))
 
think this may be doing it will come back with what I find
 
thanks again

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.