March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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
User | Count |
---|---|
117 | |
77 | |
58 | |
52 | |
46 |
User | Count |
---|---|
171 | |
117 | |
63 | |
57 | |
51 |