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.
Hi,
I have a huge table with transport data.
Route - is column with initial route
Desired output route - is column I would like to calculate which is next route taken by driver based on:
1. Filtering by registration plate (has to be exact same).
2. Dates - filter only loads taken within 2 days of previous unloading date.
Route | Loading date | Unloading date | Registration plate | Desired output date | Desired output Route |
Chicago - Ontario | 07-11-2019 | 08-11-2019 | 1ABC | no load taken | no load taken |
Atlanta - New York | 14-11-2019 | 15-11-2019 | 1ABC | 15-11-2019 | New York - Chicago |
New York - Chicago | 15-11-2019 | 18-11-2019 | 1ABC | 18-11-2019 | Chicago - Ontario |
Chicago - Ontario | 18-11-2019 | 19-11-2019 | 1ABC | 19-11-2019 | Los Angeles - New York |
Los Angeles - New York | 19-11-2019 | 20-11-2019 | 1ABC |
I tried below formula but it shows incorrect value:
Desired output date = CALCULATE(FIRSTNONBLANK(Table1[Loading date];1);FILTER(ALL(Table1);Table1[Loading date]<=[Unloading date]+2))
I would very much appreciate your help - I tried multiple lookup values and first non blank but have huge troubles with the syntax.
Solved! Go to Solution.
Hi @zuzaarbuza
See if the following DAX statement for calculated column works for:
Next route =
VAR RegistrationPlate = RouteTable[Registration plate]
VAR UnloadingDate = RouteTable[Unloading date]
RETURN
MAXX (
TOPN ( 1,
FILTER (
RouteTable,
RouteTable[Registration plate] = RegistrationPlate
&& RouteTable[Unloading date] > UnloadingDate
&& RouteTable[Loading date]
<= DATE ( YEAR ( UnloadingDate ), MONTH ( UnloadingDate ), DAY ( UnloadingDate ) + 2 )
),
RouteTable[Loading date], ASC
), RouteTable[Route]
)
Let us know if that was helpful.
Best
David
Hi @zuzaarbuza
See if the following DAX statement for calculated column works for:
Next route =
VAR RegistrationPlate = RouteTable[Registration plate]
VAR UnloadingDate = RouteTable[Unloading date]
RETURN
MAXX (
TOPN ( 1,
FILTER (
RouteTable,
RouteTable[Registration plate] = RegistrationPlate
&& RouteTable[Unloading date] > UnloadingDate
&& RouteTable[Loading date]
<= DATE ( YEAR ( UnloadingDate ), MONTH ( UnloadingDate ), DAY ( UnloadingDate ) + 2 )
),
RouteTable[Loading date], ASC
), RouteTable[Route]
)
Let us know if that was helpful.
Best
David
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |