Forum Discussion

Steven_Wu's avatar
Steven_Wu
Frequent Visitor
3 years ago
Solved

How could I transform the table based on date and specific column at the same time with DAX?

Hi, All,

I have a dataframe as follow. There are 2 players' training records.

For calculating and present the current completion status, I have to filter the current table based on the Status and Latest Date.

 

Status: Only keep the single completed activity and incomplete activity. If the activity is completed and have duplicate name. Just remove it.

Completion Date: Just keep the latest completion date.

 

Is there any way I could conver the Table A to Table B? Thank you.

Table A

PlayerTraining IDActivity NameCompletion DateStatus
A23FFootball3/2/2023Completed
A22FFootball9/1/2022Completed
A23BBaseball--Incompleted
A22BBaseball--Incompleted
A23TTennis--Incompleted
A22TTennis--Incompleted
B23FFootball4/2/2023Completed
B22FFootball--Incompleted
B23BBaseball--Incompleted
B22BBaseball--Incompleted

 

Table B

PlayerActivity NameCompletion DateStatus
AFootball3/2/2023Completed
ABaseball--Incompleted
ATennis--Incompleted
BFootball4/2/2023Completed
BBaseball--Incompleted

 

2 Replies

  • Hi Steven_Wu,

    You could try creating a new table in Table Tools via this code:

    In plain text:

    Table = SUMMARIZE ( 
        data, 
        [Player], 
        [Activity Name], 
        "Completion Date", 
        MAX ( data[Completion Date] ),
        "Status", 
        IF ( "Completed" IN VALUES ( data[Status] ), "Completed", "Incompleted" )
     )

     

    Best Regards,

    Alexander

    My YouTube vlog in English

    My YouTube vlog in Russian

  • Steven_Wu's avatar
    Steven_Wu
    Frequent Visitor

    Thank you, Alexander,

    it's what I need. Thank you so much~