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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CloudMonkey
Post Prodigy
Post Prodigy

2 linked tables with different reference dates, need to present on same axis

Hi,

 

I have 2 tables, Orders and Deliveries. I need to create a table that lists the number of orders and deliveries by month. I’m confused because I can only use 1 column as an axis but I have 2 date columns (one in the Orders table and one in the Deliveries table). The tables are linked but I can’t just use the Order date as the axis because this will just list all deliveries by their order date (not their delivery date).

 

Please can you tell me how to create a table as per the last screenshot below?

 

Orders table:

orders 0926am.JPG

 

Deliveries table:

deliveries 0926am.JPG

 

Relationships (I tried to create a common calendar but I can't make both date relationships active)

relationships 0926am.JPG

 

Current output (incorrect because deliveries are being mapped by the order date):

visualisation (correct) 0952am.JPG

 

 

Target output (orders mapped by order date, deliveries mapped by delivery date - and both on the same month axis). Please can you tell me how to create this table in Power BI?

visualisation (correct) 0926am.JPG

 

Thank you for your help!

 

CM

9 REPLIES 9
v-diye-msft
Community Support
Community Support

Hi @CloudMonkey 

 

If you've fixed the issue by your own please kindly share your solution. if the above posts help, please kindly mark it as a solution to help others find it more quickly. thanks!

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Ashish_Mathur
Super User
Super User

Hi,

There should not be a relationship between the Order and Deliveries Table.  There should just be 2 active relatinships - From Date column of Orders Table to the Date column of the Calendar Table and from the Date column of the Deliveries Table to the Date column of the Calendar Table.  To your visual, drag dates from the Calendar Table and write these measures:

Measue1 = COUNTA('Orders'[Delivery ID])

Measure2 = COUNTA(Deliveries'[Delivery ID])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
smpa01
Super User
Super User

@CloudMonkeyI may have what you need.

 

From Orders_table and Deliveries Table I created a following table called

DateTbl
DateTbl = 
VAR Summarize_Delivery = SELECTCOLUMNS(Deliveries,"Date",Deliveries[DeliveryDate])
VAR Summarize_Orders = SELECTCOLUMNS(Orders,"Date",Orders[OrderDate])
VAR Union_All=Union(Summarize_Delivery,Summarize_Orders)
RETURN
Union_All
create Calulated Columns as following
Delivery_ID = LOOKUPVALUE(Deliveries[DeliveryID],Deliveries[DeliveryDate],DateTbl[Date])
Order_ID = LOOKUPVALUE(Orders[DeliveryID],Orders[OrderDate],DateTbl[Date])
create Measures as following
Delivery_Count = COUNT(DateTbl[Delivery_ID])
Order_Count = COUNT(DateTbl[Order_ID])
resulting table as following
cx.PNG

Now when you plot

xc.PNG

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
jdbuchanan71
Super User
Super User

@CloudMonkey 

One thing you could do is move the delivery date to the orders table.  Then  you link both date fields to your dates table and invoke the second relationship when needed.  In the image blow the inactive (dotted line) relationship is between 'Dates'[Date] and 'Orders'[DeliveryDate]

DeliveryDate.jpg

Then a couple of example measures to show how the relationships are used.

Amount = SUM ( Orders[OrderAmount] )
Amount by Delivery = 
CALCULATE(
    [Amount],
    USERELATIONSHIP( Orders[DeliveryDate], Dates[Date] )
)

AmountByDelivery.jpg

I have attached my sample file for you to look at.

PradipMCT
Resolver II
Resolver II

Hi @CloudMonkey 

 

Your relationship could be a problem. 

 

Connect Orders table to Calendar table and Delivery table to Calendar table. No Relationship needed between Orders table and Deliveries table.

 

Once the relationship is complete, now Pull the Date from Calendars table, and the respective fields from Orders and Delivery table can be dragged to this table. 

 

Hope this solves your problem!

 

If I have answered your question then please do mark this as a solution.

 

Regards,

Pradip Microsoft Certified Trainer

Pradip's YouTube Channel

Thanks guys but I think I need to keep the link between Orders and Deliveries because that database structure will be needed later on for other analysis. I tried the below approach, what do you think? Is it good database structure (I'm not very experienced so am concerned about making mistakes that will make life harder later!)?

 

screenshot 3.JPG

 

screenshot 2.JPG

 

Many thanks for your help!

 

CM

Hi @CloudMonkey ,

 

The solution given by @Anonymous and I are the ideal way to link the data base to the calendar table. It will be more helpful to use time intelligence functions here.

 

You can get the report that you want in the relationship solutions given earlier. What you have used wont be a good data base architecture.

 

Regards,

Pradip Microsoft Certified Trainer

Pradip's YouTube Channel

Anonymous
Not applicable

Hi @CloudMonkey,

Ideally, there should not be any relationships between your fact tables (Orders and Delivery in your scenario).

The data model should ideally be a Star schema or snow flake schema.

Thanks.

Anonymous
Not applicable

Hi,

Here's what you need to do:th

1. Create a Calendar dimension and join the table Orders and Delivery to it.

2. Remove the relationship between Orders and Delivery table.

result.PNG

3. Create 2 measures as below:

Deliveries = COUNTROWS( Delivery )
Orders = COUNTROWS( Orders )

4. Create a matrix visual and drag these 2 measures against dates:

result.PNG

Thanks.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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