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

Flight data to roster schedule

hi,

i have flight data as below

person column, status column, date column

person1, fly in, 1/2/21

person1, fly out, 11/2/21

person2, fly in 3/2/21

person2, fly out, 23/2/21

 

how do i create a new table or colum to expand the dates in between with the following rules:

 

Dates beteween fly in and fly out is filled in with status Work

Dates between fly out and fly in is filled with status Home.

 

Thanks in advance.

Regards,

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @ChimDen,

You can try to use following calculate table formula to expand raw table and replace the status:

 

Expand = 
VAR _calendar =
    CALENDAR (
        MINX ( ALL ( 'Sample'[record date] ), [record date] ),
        MAXX ( ALL ( 'Sample'[record date] ), [record date] )
    )
RETURN
    SELECTCOLUMNS (
        FILTER (
            CROSSJOIN ( VALUES ( 'Sample'[person] ), _calendar ),
            VAR currPerson = [person]
            RETURN
                [Date]
                    >= MINX ( FILTER ( ALL ( 'Sample' ), [person] = currPerson ), [record date] )
                    && [Date]
                        <= MAXX ( FILTER ( ALL ( 'Sample' ), [person] = currPerson ), [record date] )
        ),
        "Person", [person],
        "Date", [Date],
        "Status",
            IF (
                [Date]
                    IN SELECTCOLUMNS (
                        FILTER ( ALL ( 'Sample' ), [person] = EARLIER ( 'Sample'[person] ) ),
                        "Date", [record date]
                    ),
                "Home",
                "Work"
            )
    )

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks Xiaoxin @v-shex-msft 

This works nicely as in the first 2 columns below (Dates, Query Status). However, the actual status is in the "Actual Status" column.

Back to original data i posted earlier, how do i change the DAX to make use of column with status "Fly in", Fly out" to get the Query status to match the Actual status plesae?

Thank you.

ChimDen
Frequent Visitor

table for the above

ChimDen_0-1621396425200.png

 

pranit828
Super User II
Super User II

Hi @ChimDen 

Based on the sampele data you have provided, create a new table as below

_Work = SUMMARIZE(table,table[person],"fly in",CALCULATE(Min(table[date]),ALLEXCEPT(table,table[person])),"fly out",CALCULATE(Max(table[date]),ALLEXCEPT(table,table[person])))



PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors