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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Guataha
Frequent Visitor

Do not show flat line in YTD graph for empty months

I have prepared a dashboard with a linegraph showing Actual YTD, Prior year YTD and Business plan YTD. I have been able to create measures that calculate the YTD and prior year YTD numbers using.  The actual numbers are only filled until September (as we do not have the October, November and December numbers yet).  For these empty months, there is a flat line. 

 

Instead of this flatline, I do not want to show anything. The line graph should stop in September, with no line for October, November and December. I have a filter on the page with the month. The line graph is disconnect from this filter. I use this filter for the other visuals on the dashboard. How could I change the measure that I do not show a line for the months after the selected month, but I do want to show the line for businesplan and actuals prior year.

 

I have a seperated data table. A seperaet table with the transactions, linke with the data table, based on transaction date.

5 REPLIES 5
amitchandak
Super User
Super User

@Guataha , Any solution worked out for you?

Do the above replies help? if you need more help make me @

Appreciate your Kudos.

@amitchandakMany thanks. Unfortunately I could not get it to work last week. Today with a fresh mind it worked. I used the second formula from you post (see below). Regarding the var _max, is it possible to use the selected date from filters? I have a filter for months and year.

 

 

 

AC YTD CF Graph = var _max = date(2020;9;30)
return
if(max('Date'[Date])<=_max; calculate([Total AC CF];DATESYTD('Date'[Date])); blank())

 

 

Nice simply answer to this query Guataha

amitchandak
Super User
Super User

@Guataha , Please refer to these example to forced YTDs

 

YTD QTY forced=
var _max = today()
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]<=_max)

 

YTD QTY forced=
var _max = today()
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//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 _max = date(year(today())-1,month(today()),day(today()))
return
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)


YTD QTY forced=
var _max = maxx('order',[Order date])
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]<=_max)


YTD QTY forced=
var _max = maxx('order',[Order date])
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//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 _max1 =maxx('order',[Order date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
return
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)

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Anonymous
Not applicable

Such questions on this forum appear very frequently. I personally wrote several answers (with code) to them. Why don't you find them using the Search facility?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors