Forum Discussion

icrmzgc's avatar
icrmzgc
Frequent Visitor
2 years ago
Solved

To add a stage column

Thank you for your help.
I would like to refer to table T_Reference and change table T_From to table T_To.
(I want to add a stage column)
Is it possible with DAX or PowerQuery?

The sample file is this.

T_Reference

ProjectMilestoneDateStage
PJ_AMS102/01/2021A
PJ_AMS208/01/2021B
PJ_AMS302/01/2022C
PJ_BMS102/01/2022A
PJ_AMS408/01/2022D
PJ_BMS208/01/2022B
PJ_BMS302/01/2023C
PJ_BMS408/01/2023D
PJ_A 01/30/2024E
PJ_B 01/30/2024E

 

T_From

DateCostProject
12/01/2020170000PJ_A
02/01/20217813PJ_A
05/01/2021782000PJ_A
08/01/20219375PJ_A
12/01/2021175000PJ_A
12/01/202137000PJ_B
02/01/202231250PJ_A
02/01/202218750PJ_B
05/02/202251000PJ_A
05/02/202223000PJ_B
08/01/20223125PJ_A
08/01/202241667PJ_B
12/01/2022413000PJ_A
12/01/2022451000PJ_B
01/30/202425000PJ_A
02/01/202312500PJ_B
05/01/20231707000PJ_B
08/01/202316667PJ_B
12/01/2023188000PJ_B
01/30/202412500PJ_B

 

T_To

DateCostProjectStage
12/01/2020170000PJ_AA
02/01/20217813PJ_AA
05/01/2021782000PJ_AB
08/01/20219375PJ_AB
12/01/2021175000PJ_AC
12/01/202137000PJ_BA
02/01/202231250PJ_AC
02/01/202218750PJ_BA
05/02/202251000PJ_AD
05/02/202223000PJ_BB
08/01/20223125PJ_AD
08/01/202241667PJ_BB
12/01/2022413000PJ_AE
12/01/2022451000PJ_BC
01/30/202425000PJ_AE
02/01/202312500PJ_BC
05/01/20231707000PJ_BD
08/01/202316667PJ_BD
12/01/2023188000PJ_BE
01/30/202412500PJ_BE

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  icrmzgc ,

     

     

    Here are the steps you can follow:

    1. Create calculated column.

    Stag =
    MINX(
        FILTER(ALL(T_Reference),    'T_Reference'[Date]>=EARLIER('T_From'[Date])&&'T_Reference'[Project]=EARLIER('T_From'[Project])),'T_Reference'[Stage])

     

    2. Result:

     

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

4 Replies

  • amustafa's avatar
    amustafa
    Solution Sage

    Hi icrmzgc , you need to define the join (relationship) between T_Reference and T_From table. You have project codes with different milestones and dates. Your T_From table just have Project codes. I used the Project codes and the Date combo in Power Query to get what you might really need. See the files in my shared drive link below.

     

    Project Cost and Stage

     

    If I answered your question, please mark this thread as accepted and Thums Up!
    Follow me on LinkedIn:
    https://www.linkedin.com/in/mustafa-ali-70133451/

     

  • icrmzgc's avatar
    icrmzgc
    Frequent Visitor

    Hello amustafa.
    Thank you for your answer and sample file.
    I didn't know that you could specify two parameters with Table.NestedJoin, so I learned a lot.

    However, unfortunately, some of the ideas I received are not able to set the stage.
    I also want to set the Stage for the 10 items in red.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  icrmzgc ,

     

     

    Here are the steps you can follow:

    1. Create calculated column.

    Stag =
    MINX(
        FILTER(ALL(T_Reference),    'T_Reference'[Date]>=EARLIER('T_From'[Date])&&'T_Reference'[Project]=EARLIER('T_From'[Project])),'T_Reference'[Stage])

     

    2. Result:

     

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

    • icrmzgc's avatar
      icrmzgc
      Frequent Visitor

      Hello, Liu Yang.
      Thank you for your reply and file.
      It's what I was looking for.
      I don't fully understand the DAX style description with my current knowledge, but I would like to be able to understand it.
      I'm really thankful to you.