I am new to powerbi DAX and struggling to compute difference between two lines.
The dataset describes a bus network and is composed of three tables. Example given below:
Table1
Transport_type, Line_number
Bus, 101
Bus, 102
Table2
Line_number, Trip, Stop_name, Stop_sequence
101, monday-101-1, stop-101-a, 1
101, monday-101-1, stop-101-b, 2
101, monday-101-1, stop-101-c, 3
101, monday-101-2, stop-101-a, 1
101, monday-101-2, stop-101-c, 3
101, monday-101-2, stop-101-b, 2
102, monday-102-1, stop-102-c, 3
102, monday-102-1, stop-102-b, 2
102, monday-102-1, stop-102-a, 1
102, monday-102-2, stop-102-a, 1
102, monday-102-2, stop-102-b, 2
102, monday-102-2, stop-102-c, 3
Table3
Stop_name, Altitude
stop-101-a, 540
stop-101-b, 560
stop-101-c, 590
stop-102-a, 230
stop-102-b, 210
stop-102-c, 170
Relationships between tables is already set in the model tab; and in the report tab i created a table and added all parameter through drag-drop.
With Table3 selected, I create a new calculated column and desperately try to compute altitude difference between each stops of the trip.
Example of expected result
Transport_type, Line_number, Trip, Stop_name, Stop_sequence, Altitude difference
Bus, 101, monday-101-1, stop-101-a, 1, 0
Bus, 101, monday-101-1, stop-101-b, 2, 20 (=560-540)
Bus, 101, monday-101-1, stop-101-c, 3, 30 (=590-560)
Bus, 101, monday-101-2, stop-101-a, 1, 0
Bus, 101, monday-101-2, stop-101-c, 3, 30 (=590-560)
Bus, 101, monday-101-2, stop-101-b, 2, 20 (=560-540)
Bus, 102, monday-102-1, stop-102-c, 3, -40 (=170-210)
Bus, 102, monday-102-1, stop-102-b, 2, -20 (=210-230)
Bus, 102, monday-102-1, stop-102-a, 1, 0
Bus, 102, monday-102-2, stop-102-a, 1, 0
Bus, 102, monday-102-2, stop-102-b, 2, -20 (=210-230)
Bus, 102, monday-102-2, stop-102-c, 3, -40 (=170-210)
Does anyone have any idea on how to combine filters from different tables to then subtract two rows ?
Thanks for your help :)