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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
JulienH
Regular Visitor

Count previous quarter

Hi all,

 

I am trying to count the numbers of entries in (excel online database) for my previous quarter. If I compare Q1 - 2016 (52 entries) to my Q2 - 2016 previous quarter (30 entries) the amount do not match. I would like to eventually calculate the difference in % from previous quarter.

 

Please help!

 

Articles this quarter = CALCULATE(COUNTX('Article Tracker',DATEADD('Article Tracker'[Publication Date], 0,QUARTER)))
Articles last quarter = CALCULATE(COUNTAX('Article Tracker',DATEADD('Article Tracker'[Publication Date],-1,QUARTER)))

Capture.PNG

1 ACCEPTED SOLUTION
JulienH
Regular Visitor

The issue I was having was because i was not using a table calendar which i created using this code.

 

DimDates = 
VAR BaseCalendar = 
    CALENDARAUTO (3)
RETURN
    GENERATE(
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR YearDate = YEAR(BaseDate)
        VAR MonthNumber = MONTH(BaseDate)
        RETURN ROW (
            "Day", BaseDate,
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT(BaseDate, "mmmm"),
            "Year Month", FORMAT(BaseDate, "mmm yy")
            )
        )

Once i had that table and linked it to my other tables everything came together.

 

Article previous quarter = CALCULATE(COUNT('Article Tracker'[Article]),PREVIOUSQUARTER(DimDates[Date]))

 

View solution in original post

5 REPLIES 5
JulienH
Regular Visitor

The issue I was having was because i was not using a table calendar which i created using this code.

 

DimDates = 
VAR BaseCalendar = 
    CALENDARAUTO (3)
RETURN
    GENERATE(
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR YearDate = YEAR(BaseDate)
        VAR MonthNumber = MONTH(BaseDate)
        RETURN ROW (
            "Day", BaseDate,
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT(BaseDate, "mmmm"),
            "Year Month", FORMAT(BaseDate, "mmm yy")
            )
        )

Once i had that table and linked it to my other tables everything came together.

 

Article previous quarter = CALCULATE(COUNT('Article Tracker'[Article]),PREVIOUSQUARTER(DimDates[Date]))

 

Hi @JulienH ,

 

I am glad you found a solution. 

Do not hesitate if you need any more help.

 

Regards,

 

LC

lc_finance
Solution Sage
Solution Sage

Hi @JulienH ,

 

 

I think the problem is that you are passing the DATEADD as a parameter to the COUNTX function, instead of passing it as a parameter of the CALCULATE function. Moreover, I think that in your case a COUNT formula would be easier, instead of a COUNTX formula.

 

Here is what I propose as new formulas:

 

Articles this quarter = CALCULATE(COUNT('Article Tracker'[Article ID]),DATEADD('Article Tracker'[Publication Date], 0,QUARTER))
Articles last quarter = CALCULATE(COUNT('Article Tracker'[Article ID]),DATEADD('Article Tracker'[Publication Date], -1,QUARTER))

Let me know if those works for you.

 

Regards,

 

LC

Interested in Power BI templates? Check out my blog at www.finance-bi.com

Thanks for looking into it @lc_finance.

 

The first formula "Article this quarter" seems to work just fine however as i entered the second one i get no results in the table. Also when i use a slicer all charts go in error mode "Can't display the visual. - ... Function 'DATEADD' expects a contiguous selection when the date column is not unique, has gaps or it contains time portion."

 

Any idea?

 

Hi @JulienH ,

 

 

could you share a sample Power BI file?

 

I'll take a look at it. You can share the file via DropBox, One Drive, Drive or another similar tool.

 

LC

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.