Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have one table (Shiptracking history) with departure, arrival, mass columns. There are entries with the same departure or same arrival date.
I would like to create another table with a calendar date, exports & imports on each day. Creating the calendar date is easy as shown below.
Calendar = CALENDAR ( MIN(MIN('Shiptracking history'[Arrival]),MIN('Shiptracking history'[Departure])), MAX(MAX('Shiptracking history'[Arrival]),MAX('Shiptracking history'[Departure])) )
Creating the Exports and Imports columns is the problem I have. First, I attempted to establish a relationship between the Date in the Calendar table and the Departure/Arrival in the Shiptracking history table. That does not seem to be legit and one of the relationships is not active.
Then I was hoping to bring in the Exports and the Imports using the following code
Exports = SUMX(RELATEDTABLE('Shiptracking history'),'Shiptracking history'[Mass]))
Imports = SUMX(RELATEDTABLE('Shiptracking history'),'Shiptracking history'[Mass]))
But clearly it doesn’t work and I get an error.
How can I generate Exports and Imports in the Calendar table, using the data in the Shiptracking history table? I also experimented with SELECTCOLUMNS but I couldn't make it work.
Solved! Go to Solution.
Hi @Anonymous,
Please remove the relationship between two tables, and try this:
Exports =
CALCULATE (
SUM ( 'Shiptracking history'[Mass] ),
FILTER (
'Shiptracking history',
'Shiptracking history'[Departure] = EARLIER ( Calendar[Date] )
)
)
Imports =
CALCULATE (
SUM ( 'Shiptracking history'[Mass] ),
FILTER (
'Shiptracking history',
'Shiptracking history'[Arrival] = EARLIER ( Calendar[Date] )
)
)
Best regards,
Yuliana Gu
Hi @Anonymous,
Please remove the relationship between two tables, and try this:
Exports =
CALCULATE (
SUM ( 'Shiptracking history'[Mass] ),
FILTER (
'Shiptracking history',
'Shiptracking history'[Departure] = EARLIER ( Calendar[Date] )
)
)
Imports =
CALCULATE (
SUM ( 'Shiptracking history'[Mass] ),
FILTER (
'Shiptracking history',
'Shiptracking history'[Arrival] = EARLIER ( Calendar[Date] )
)
)
Best regards,
Yuliana Gu
Awesome, thank you so much for your response, this works for me. Much appreciated.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
62 | |
62 | |
52 | |
39 | |
24 |
User | Count |
---|---|
85 | |
57 | |
45 | |
43 | |
38 |