Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
I have created the following calcs for current & previous months counts when joining to a date table, however they dont account for the year which is causing me issues. Is there a way to add year to these existing calcs?
My aim is to get current & previous months counts and then use a day field (1-31) to display these in a graph for comparison.
Current Month = CALCULATE(count(Table1[column]),FILTER('Date Table',MONTH('Date Table'[Date])=MONTH(now())))
Previous Month = var current_month= MONTH(TODAY()) return
CALCULATE(COUNT(Table1[column]),FILTER('Date Table',MONTH('Date Table'[Date])=current_month -1))
Thanks!
Solved! Go to Solution.
I was overthinking this 😀. Used these calcs and then applied slicers for month & year on the graph
I was overthinking this 😀. Used these calcs and then applied slicers for month & year on the graph
Hi @blowers ,
So for the understanding of this date, previous month in a way you did it:
dates =
VAR _today = TODAY ()
VAR _year = YEAR ( _today )
VAR _month = MONTH ( _today )
VAR _previousMonth = _month - 1
RETURN
"This month-year: " & _year & " " & _month & " " &
"Previous month-year: " & _year & " " & _previousMonth
Your date table can and I believe should contain columns like Month, Year, etc. It is easy to build in Power Query, DAX, etc. So you'll have something like this:
Current Month =
VAR _today = TODAY ()
VAR _year = YEAR ( _today )
VAR _month = MONTH ( _today )
RETURN
CALCULATE ( COUNT ( Table1[column] ), 'Date Table'[Month] = _month, 'Date Table'[Year] = _year )
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
I get an error when using this calculation, DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
I do have a date table in my model, month is populated as Jul, Aug, Sep etc, and year is populated as 2021, 2022, 2023 etc. Any ideas where im going wrong?
hi @blowers ,
what does this mean: "use a day field (1-31) to display these in a graph for comparison."?
So the graph should have the days of the month, and then the current month and previous month counts over that monthly period. I keep having issues as it keeps counting the previous year in the graph calulations.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |