Power BI: calculate values with one calendar
When I analyze data, some tables may have multiple date columns, for instance, open date, update date, close date, etc. so to manage values based on dates, the simpler way is to create a calendar for each of them, at the end, I may have 3, 4 or more calendar tables but the best way to do it, it is to have one unique and single calendar for all of them. Let´s take an example, I have this table:

I want to count how many tickets per month, for that, I will have to regroup the date. I will select the “opened” column then click on “data groups -> new data groups”:

About the fields:
- Name: change it if you want
- Bin size: put the number to group then select the type

For instance, I put 1 to group all date in 1 month. For a quarter, I will put “3 months”. To count by day, I will put “1 days”, etc. I will do the same thing for the “closed” column:

I will create a monthly calendar (for more information, read Power BI: create an automatically updated calendar):

I will create 2 relationships, one active and one inactive:
![]() |
![]() |
NOTE: no matter how many date columns, only 1 should be active and the others should be inactive.
Now, for each formula that should involve the “inactive” relationship, I have to include the USERELATIONSHIP function:
CALCULATE(formula,USERELATIONSHIP('table'[argument],'calendar'[argument]))
For instance, to count how many tickets for the “closed”:

NOTE: as said above, for “opened”, since the relationship is “active”, there is no need to use the function
Let´s create a chart to see the result:
![]() |
![]() |
Important thing to know, the USERELATIONSHIP function only works for formula but it is not working for filtering. For instance, I will create a table, a slicer and 2 cards; with the chart, I select April:


As we can see, only in the table, “closed” is not showing correctly (2 results instead of 3). Even if I use the slicer, I will get the same result. The reason is that the chart and the slicer is using the calendar which has an “active” relationship with “opened” so the only solution is to create another calendar for “closed” and repeat the same process as above but for “closed” instead of “opened”:
- The relationship:
- The formula of “measure 2”:
The result:


Now, in the table, “closed” is showing correctly but not “opened” so to display both versions in 1 single page, use bookmarks, for more information, read Power BI: bookmarks or pages ?
Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...
-
Refresh Power BI
From the Power BI Service, I can set refresh but, for instance, there is no option to do it monthly or each time a change is made...
-
Power BI alerts to be sent by email from an excel file based on condition
I will explain how to send a list of emails from an excel file after creating alerts...