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
ManojMunjeti
New Member

Show data for last 8 quarters on line chart from a quarter value selected

I am working on a dax function where the requirement is
Requirement: I select a quarter value from slicer and my line chart shows data for the last 8 quarters.

Additional requirement: If there is no data for a specific quarter the data should show 0 on the line chart

My work: I did create another calendar table called previous dates and here is my dax.

 
Total Risk Events Past 24 Months =
var ReferenceDate = MAX(Dates[Date])
var PreviousDates =
DATESINPERIOD(
'Previous Date'[Date],
ReferenceDate,
-24,
MONTH)
var Result =
CALCULATE((DISTINCTCOUNT('Risk Events'[Event ID])),
REMOVEFILTERS(Dates),
KEEPFILTERS(PreviousDates),
USERELATIONSHIP(Dates[Date],'Previous Date'[Date])
)
Return
Result
 
and I do get the result I want except that the quarter where there is no value assigned gets skipped from the axis.

Where there is data for all 8 quarters:
ManojMunjeti_0-1650990383255.png

Where there is no data for all 8 quarters from a selected quarter:

ManojMunjeti_1-1650990433500.png

Despite no values for all 8 quarters, I want the values to all show up on the chart and show as 0.
Your ideas on this is much appreciated.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ManojMunjeti , if you select one qtr and what to show more than that you need an independent date table in the slicer

 

example

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -24) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

refer

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

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

1 REPLY 1
amitchandak
Super User
Super User

@ManojMunjeti , if you select one qtr and what to show more than that you need an independent date table in the slicer

 

example

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -24) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

refer

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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