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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
POSPOS
Post Patron
Post Patron

Show last 8 Quarters using DAX

Hi All,

I have a requirement to show only the last 8 quarters in the report.

If there is no data in a particular quarer then show as zero. Attached below is a sample chart and pbix here.

 

POSPOS_0-1706295626326.png

Can someone pls suggest on how to achieve this using DAX.

Thank you

 

1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@POSPOS 

 

output : 

Daniel29195_0-1706298384399.png

 

 

measure : 

Measure =
var m = CALCULATE(MAX('154'[Date]), ALL('154'))

var datasource =
CALCULATETABLE(
    all('154'[Date]),
    '154'[Date] >= EDATE(m,-8 * 3 ),
    ALL('154')
)

RETURN
 IF( MIN('154'[Date])>=EDATE(m,-8 * 3 ) , COUNT('154'[Seq No]),blank())

   
 
If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. I would appreciate hitting that kudos button 👍🤠

View solution in original post

5 REPLIES 5
Daniel29195
Super User
Super User

@POSPOS 

 

output : 

Daniel29195_0-1706298384399.png

 

 

measure : 

Measure =
var m = CALCULATE(MAX('154'[Date]), ALL('154'))

var datasource =
CALCULATETABLE(
    all('154'[Date]),
    '154'[Date] >= EDATE(m,-8 * 3 ),
    ALL('154')
)

RETURN
 IF( MIN('154'[Date])>=EDATE(m,-8 * 3 ) , COUNT('154'[Seq No]),blank())

   
 
If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. I would appreciate hitting that kudos button 👍🤠

@Daniel29195  - 
After testing this with more data, I noticed that the measure is showing only last 6 quarters instead of 8.
I have attached a sample report here.
Could you please advise why I am getting only 6 quarters instead of 8.
Thank you.

@POSPOS 

Measure =
var m = CALCULATE(MAX('data8Q (2)'[Submit Date]), ALL('data8Q (2)'))

var datasource =
CALCULATETABLE(
    values('data8Q (2)'[Submit Date]),
    'data8Q (2)'[Submit Date] >= EDATE(m,-8 * 3 ),
    ALL('data8Q (2)')
)

RETURN
 
     CALCULATE(COUNT('data8Q (2)'[SerNo]) , datasource)
   
it will show 7 quarters.
 
if you remove the filter on activation is not blank() , it will show  8
Daniel29195_1-1706741225734.png

 

 Daniel29195_0-1706741124483.png

 

Thanks @Daniel29195  - Our requirement is to apply activation complete filter to exclude all the blanks dates.

@POSPOS 
simply add the filter slicer, 
but then ,

the first quarter in the chart will disappear since in this quarter the activation complete is blank () 

so it will show only 7 quarters. 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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