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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
psmurphy
Regular Visitor

Count and graph multiple dates in the same table

Hi,

 

I have searched for a solution and cannot find anything that is obvious but this must be a common scenario

 

I have a table with 5 seperate dates that means the same thing just done 5 times and usually on different dates and I need to total\sum\count these so I can graph it to get a single total across these dates for each month\year

 

Below is the table\fields

 

psmurphy_0-1721913977054.png

 

Data

 

psmurphy_0-1721916046595.png

 

 

I have come across using a dates table and USERELATIONSHIP but the examples and solutions are a little beyond my capability and assume some indepth knowledge of PowerBI

 

How would I go about solving this, a simple step by step solution would be fantastic

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @psmurphy 
Unfortunately, there's no simpler way to work with different dates from an active primary relationship and other inactive relationships while leveraging the USERELATIONSHIP function as you mentioned. Let me try to explain with a simple example. When you visualize multiple measures based on a single date column, it implies that date is a common field between all of them, but the events occurring on that date can vary. For instance, in an orders table, there's an order date and a shipping date, and typically an order isn't shipped on the same day it's created. To enable counting orders with different statuses (created/shipped) based on a common date field, we need to ensure that the relationship with the calendar table for the specific measure only considers the relevant date. This is why Power BI allows us to create multiple inactive relationships, or as I call them "dormant" relationships, which remain inactive until we explicitly activate them within a measure using the USERELATIONSHIP function.

Back to the example of orders to make it works the model should look like this:

Ritaf1983_0-1721967972238.png

2 relationships with the calender :
1. Active - by order date
2. inactive - by ship date

Ritaf1983_1-1721968116435.png

Now lets say I want to show created and shipped orders by month.
I'll need to create 2 measures :

orders created  qty = DISTINCTCOUNT('orders'[Order ID])
**here I don't need any manipulations because this will work with the active ralationship
shipped orders = CALCULATE(DISTINCTCOUNT(orders[Customer ID]),USERELATIONSHIP(orders[Ship date],'Calendar'[Date]))
**the same logic , but with the activating a needed relationship
Result:
Ritaf1983_2-1721968647565.png

The pbix with the example is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

mickey64
Super User
Super User

For youre reference.

 

Step 0: I use these data below.

mickey64_0-1721970638708.png

 

Step 1: I demote headers on Power Query Editor.

- Before -

mickey64_1-1721970689607.png

- After -

mickey64_2-1721970728662.png

 

Step 2: I merge columns for 5 times.

mickey64_3-1721970888613.png

mickey64_5-1721970920576.png

mickey64_8-1721970985011.png

mickey64_7-1721970960372.png

mickey64_9-1721971009094.png

 

Step 3: I promote these headers.

mickey64_10-1721971065666.png

 

Step 4: I unpivot these columns.

mickey64_11-1721971137715.png

 

 

Step 5: I split 'Attribute' column by '_'.

mickey64_12-1721971187061.png

 

Step 6: I split 'Value' column by '_'.

mickey64_13-1721971209230.png

 

Step 7: I filter 'Value.2' Column.

mickey64_14-1721971388900.png
mickey64_15-1721971410679.png

 

Step 8: I make a matrix.

mickey64_16-1721971484286.png

View solution in original post

2 REPLIES 2
mickey64
Super User
Super User

For youre reference.

 

Step 0: I use these data below.

mickey64_0-1721970638708.png

 

Step 1: I demote headers on Power Query Editor.

- Before -

mickey64_1-1721970689607.png

- After -

mickey64_2-1721970728662.png

 

Step 2: I merge columns for 5 times.

mickey64_3-1721970888613.png

mickey64_5-1721970920576.png

mickey64_8-1721970985011.png

mickey64_7-1721970960372.png

mickey64_9-1721971009094.png

 

Step 3: I promote these headers.

mickey64_10-1721971065666.png

 

Step 4: I unpivot these columns.

mickey64_11-1721971137715.png

 

 

Step 5: I split 'Attribute' column by '_'.

mickey64_12-1721971187061.png

 

Step 6: I split 'Value' column by '_'.

mickey64_13-1721971209230.png

 

Step 7: I filter 'Value.2' Column.

mickey64_14-1721971388900.png
mickey64_15-1721971410679.png

 

Step 8: I make a matrix.

mickey64_16-1721971484286.png

Ritaf1983
Super User
Super User

Hi @psmurphy 
Unfortunately, there's no simpler way to work with different dates from an active primary relationship and other inactive relationships while leveraging the USERELATIONSHIP function as you mentioned. Let me try to explain with a simple example. When you visualize multiple measures based on a single date column, it implies that date is a common field between all of them, but the events occurring on that date can vary. For instance, in an orders table, there's an order date and a shipping date, and typically an order isn't shipped on the same day it's created. To enable counting orders with different statuses (created/shipped) based on a common date field, we need to ensure that the relationship with the calendar table for the specific measure only considers the relevant date. This is why Power BI allows us to create multiple inactive relationships, or as I call them "dormant" relationships, which remain inactive until we explicitly activate them within a measure using the USERELATIONSHIP function.

Back to the example of orders to make it works the model should look like this:

Ritaf1983_0-1721967972238.png

2 relationships with the calender :
1. Active - by order date
2. inactive - by ship date

Ritaf1983_1-1721968116435.png

Now lets say I want to show created and shipped orders by month.
I'll need to create 2 measures :

orders created  qty = DISTINCTCOUNT('orders'[Order ID])
**here I don't need any manipulations because this will work with the active ralationship
shipped orders = CALCULATE(DISTINCTCOUNT(orders[Customer ID]),USERELATIONSHIP(orders[Ship date],'Calendar'[Date]))
**the same logic , but with the activating a needed relationship
Result:
Ritaf1983_2-1721968647565.png

The pbix with the example is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors