cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HigherQuality Frequent Visitor
Frequent Visitor

How to track previous location by serial number and date

I'm trying to track the movement of a piece of equipment with the current location and the date. Example: 

 

Serial NumberDateLocationExpected Out Come
12307/10/2018New YorkNew York
1237/20/2018BaltimoreNew York
12308/10/2018MiamiBaltimore
12308/12/2018RichmondMiami

Etc..

 

Right now my code is only find the orgin of where the serial number was located. So everything in the Expected column is reading New York.

 

Orgin = VAR Orgin =
    CALCULATE (
        MIN ( Table_owssvr[Utilization Date] ),
        ALLEXCEPT (Table_owssvr,Table_owssvr[Serial Number] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( Table_owssvr[Port] ),
        FILTER (
            ALLEXCEPT ( Table_owssvr, Table_owssvr[Serial Number]),
            Table_owssvr[Utilization Date] = Orgin
        )
    )

 

Expected Out Come is what I need the column to say. The Date isn't always ordered and the same location can come up more then once. I am using this column on a flow map to track the location of the equipment.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How to track previous location by serial number and date

Hi @HigherQuality 

Try this:

Orgin =
VAR Orgin =
    CALCULATE (
        MAX ( Table_owssvr[Utilization Date] );
        Table_owssvr[Utilization Date] < EARLIER ( Table_owssvr[Utilization Date] );
        ALLEXCEPT ( Table_owssvr; Table_owssvr[Serial Number] )
    )
VAR Res_ =
    CALCULATE (
        SELECTEDVALUE ( Table_owssvr[Port] );
        Table_owssvr[Utilization Date] = Orgin
ALLEXCEPT ( Table_owssvr; Table_owssvr[Serial Number] ); ) RETURN IF ( NOT ISBLANK ( Res_ ); Res_; Table_owssvr[Port] )

View solution in original post

1 REPLY 1
Super User
Super User

Re: How to track previous location by serial number and date

Hi @HigherQuality 

Try this:

Orgin =
VAR Orgin =
    CALCULATE (
        MAX ( Table_owssvr[Utilization Date] );
        Table_owssvr[Utilization Date] < EARLIER ( Table_owssvr[Utilization Date] );
        ALLEXCEPT ( Table_owssvr; Table_owssvr[Serial Number] )
    )
VAR Res_ =
    CALCULATE (
        SELECTEDVALUE ( Table_owssvr[Port] );
        Table_owssvr[Utilization Date] = Orgin
ALLEXCEPT ( Table_owssvr; Table_owssvr[Serial Number] ); ) RETURN IF ( NOT ISBLANK ( Res_ ); Res_; Table_owssvr[Port] )

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 149 members 1,662 guests
Please welcome our newest community members: