Forum Discussion
String Based New Column
- 6 years ago
Hi awitt,
This calculated colulmn Formula should get the correct orderId for each tracking number
Correct Order ID = var trackingNumber = [Tracking Number] return CALCULATE(max('Table'[Order ID]), FILTER(ALL('Table'), 'Table'[Tracking Number] = trackingNumber && LEFT('Table'[Order ID], 1) = "1"))Then this calc column would create the correct Order Track
Correct OrderTrack = 'Table'[Correct Order ID] & 'Table'[Tracking Number]The Min Max Dates can then be derived with a measure or a calculated column.
Hope this helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!
awitt - OK, so how do you know the correct order id? Sorry, I'm missing something. Is it the Tracking number? If so, would suggest doing a Merge against itself based on the tracking number and then go from there.
- awitt6 years ago
Helper III
Greg_Deckler The correct OrderID always starts with a 1 and the incorrect orderID never seems to start with a 1. The tracking numbers for both are always the same and correct.
So something along the lines of Case/When '1%' if you were to do this in SQL.
- richbenmintz6 years ago
Resident Rockstar
Hi awitt,
This calculated colulmn Formula should get the correct orderId for each tracking number
Correct Order ID = var trackingNumber = [Tracking Number] return CALCULATE(max('Table'[Order ID]), FILTER(ALL('Table'), 'Table'[Tracking Number] = trackingNumber && LEFT('Table'[Order ID], 1) = "1"))Then this calc column would create the correct Order Track
Correct OrderTrack = 'Table'[Correct Order ID] & 'Table'[Tracking Number]The Min Max Dates can then be derived with a measure or a calculated column.
Hope this helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!- richbenmintz6 years ago
Resident Rockstar
Hi awitt,
Here are the measures to get the Min Max and days between
Min Dep Date = CALCULATE(MIN('Table'[Departure Date]), FILTER(ALL('Table'), 'Table'[Correct Order ID] = MIN('Table'[Correct Order ID]))) Max Current Date = CALCULATE(Max('Table'[Current Date]), FILTER(ALL('Table'), 'Table'[Correct Order ID] = MIN('Table'[Correct Order ID]))) Days Between = DATEDIFF('Table'[Min Dep Date], 'Table'[Max Current Date], DAY)Hope this Helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!
- Greg_Deckler6 years ago
Community Champion
awitt , ImkeF may have a Power Query way of doing it. You could do it with DAX as richbenmintz states. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586