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
Anonymous
Not applicable

Visualize partial months in bar chart

I have sales data that goes through December 21st 2021 I also have last year's sales data through December 21st 2020.  Note that I blanked out all data past todays (12/21) date as I want to compare apples to apples.  The table looks fine and I have last year's sales by month (November last full month) and December is showing day data to the 20th.  I would like to have a bar chart showing all the completed months and the month to date for December in the same bar chart.  Right now my last bar on chart is November as it is the last complete month.  Any way to force power bi visualization to include December month to date and add up this year vs last year through the 20th? 

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Try these measures

Sales TY = CALCULATE(SUM('Table'[Sales]),Dates[Year]=YEAR(TODAY()))
Sales LY = 
VAR _month = SELECTEDVALUE(Dates[Month])
RETURN
CALCULATE(SUM('Table'[Sales]),ALL(Dates),Dates[Year]=YEAR(TODAY())-1,Dates[Month]=_month,Dates[Date]<=EDATE(TODAY(),-12))

21122404.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@Anonymous , Try datesytd with additional filter

 

YTD QTY forced=
var _max1 = today() //or maxx(allselected('Order'),'order'[Date])
var _max = format(_max,"MMDD")
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date', format('Date'[Date],"MMDD")<=_max))


YTD QTY forced=
var _max = today()//or maxx(allselected('Order'),'order'[Date])
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

 

LYTD QTY forced=
var _today = maxx(allselected('Order'),'order'[Date])
var _max = date(year(_today)-1,month(_today),day(_today))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

 

 

Alternate options in comments

 

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
Anonymous
Not applicable

Thanks for getting back to me. I appreciate it.  I tried to create a measure utilizing the above with no luck.  I am certain it is because I don't fundamentally understand it. 

My current measure is 

1. CY GWP = if(LASTDATE(Dates[Date])>TODAY(),BLANK(),CALCULATE(SUM('2. Data for all Departments'[3. GWP])))
 
GWP is nothing more than Sales. 
 
I am using Last Years Sales formula as follows:
 
1. LY GWP = if(LASTDATE(Dates[Date])>TODAY(),BLANK(),CALCULATE(SUM('2. Data for all Departments'[3. GWP]),DATEADD(Dates[Date],-1,YEAR)))
 
The below is the bar chart I want to move out to December and reflect sales to date. (note below is just an item count, but wanted to illustrate what the bar graph is showing.  
 
erickittleson_0-1640178432754.png

 

 
Pretty simple, but just want to reflect a partial month for December rather than cutting the bar graph off at November, which is obviously the last full month of data.  
 
 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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