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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
prekapRev
Frequent Visitor

Counts based on multiple dates in a table

I have a table with multiple date fields (Order Date, Ship Date, Delivery Date). I need to report on counts of sales, shipment and delivery for each month where either sale, shipment or delivery was made. 

 

Here is an example of mockup source data

Sales_Order_NumProductOrder_DateShip_DateDelivery_Date
1P18/19/20208/29/20209/3/2020
2P18/24/20209/3/20209/13/2020
3P19/3/20209/8/20209/19/2020

 

I need to display counts like this

MonthOrder CountShipment CountDelivery Count
August210
September123

 

I have a date table and created one active (on Order date) and 2 indirect (ship and delivery date) relations.

I created measures for shipment and Delivery counts using USERELATIONSHIP like below

 

Ship_Count = CALCULATE(count(Sales[Sales_Order_No]), USERELATIONSHIP(Cal_Date[Date], Sales[Ship_Date]))
Delivery_Count = CALCULATE(count(Sales[Sales_Order_No]), USERELATIONSHIP(Cal_Date[Date], Sales[Delivery_Date]))
 
But I am still getting result like below (shipment and Delivery counts are same as order count)
 

Month is from Calendar table

MonthOrder CountShipment CountDelivery Count
August222
September111

 

How do I get the shipment and delivery counts displayed correctly?

1 ACCEPTED SOLUTION

Hi @prekapRev  -

 

Force your relationships between Cal_Date and Sales to be 1-to-many (Cal_Date on the 1 side) and it should work for you.

 

2020-08-21 09_18_04-Multi_Dates - Power BI Desktop.png

 

2020-08-21 09_19_53-Multi_Dates - Power BI Desktop.png

 

Hope this helps

David

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
dedelman_clng
Community Champion
Community Champion

Hi @prekapRev  - I cannot reproduce your results. I get your expected output when I put your code in (although the DAX says "Sales Order No", while the data says "Sales Order Num", but I assume that was just an error in typing).

 

2020-08-20 15_15_51-scratch2 - Power BI Desktop.png

 

Order Count = CALCULATE(COUNT(Sales[Sales_Order_Num]))

Ship_Count = CALCULATE(count(Sales[Sales_Order_Num]), 
               USERELATIONSHIP(DateTab[Date], Sales[Ship_Date]))

Delivery_Count = CALCULATE(count(Sales[Sales_Order_Num]), 
               USERELATIONSHIP(DateTab[Date], Sales[Delivery_Date]))

 

2020-08-20 15_19_20-scratch2 - Power BI Desktop.png

 

Perhaps you left something out of the explanation that makes the situation more complicated?

 

David

 

 

@dedelman_clng I want to attach my pbix file but I don't know how to attach any files here. I have done it exactly like you are showing in your solution but my result is different. not sure why.

Put it on a Dropbox, google drive or OneDrive and put the link into a post. 

Hi @prekapRev  -

 

Force your relationships between Cal_Date and Sales to be 1-to-many (Cal_Date on the 1 side) and it should work for you.

 

2020-08-21 09_18_04-Multi_Dates - Power BI Desktop.png

 

2020-08-21 09_19_53-Multi_Dates - Power BI Desktop.png

 

Hope this helps

David

Changing cardinality fixed the problem. Thanks! I wonder though that why should that be the problem 🤔

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.