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
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)))Solved! Go to Solution.
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]))
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
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 54 | |
| 37 | |
| 32 | |
| 17 | |
| 15 |
| User | Count |
|---|---|
| 66 | |
| 66 | |
| 39 | |
| 34 | |
| 25 |