Forum Discussion

Anonymous2023's avatar
Anonymous2023
New Member
3 years ago

Index match, calculation with multiple option filter

Hi Team,

 

I am new to Power BI and so far has spent lots of time search relevent answer for my analysis.

I am always an excel users, but due to the size of my new datasets (>1GB), Power BI appear to be a better option.

Okay let me get this straight: I would like to calculate the duration of the activities taking place for each participants, but I only have data of specific milestones of each participants as rows. How should I proceeed?

My table

ParticipantMilestoneDate
1011123Start1989/1/1
1011198start11988/1/1
1011167End2000/2/1
1011123end12002/3/1
1011198end2011/1/1
1011167start1989/1/1
1011123pause1998/1/1

 

My expected results 

ParticipantsStart timeEnd timeDuration
10111231989/1/12002/1/113 year
10111671989/1/12000/1/111 year
10111981988/1/12011/1/1

23 year

 

My thoughts (in excel logic):

1. Create additional column that converts "Start", "start" and "start1" as "start" (and for "end" as well)

2. Indexmatch the time for each participant in start time and end time columns.

3. Calculate the duration.

 

I was stopped at the first step, I can't really create a new table with filter that includes all the "start" related status. (OR and || didnt work unforutnately)

Happy to see how I could proceed, thank you.

3 Replies

  • NaveenGandhi's avatar
    NaveenGandhi
    Icon for Memorable Member rankMemorable Member

    Hello Anonymous2023 

    Try the below dax to create a new table.


    Milestone_Table =
    ADDCOLUMNS (
    SUMMARIZE (
    'Table (2)',
    'Table (2)'[Participant],
    "Start_Time",
    CALCULATE (
    MIN ( 'Table (2)'[Date] ),
    'Table (2)'[Milestone] = "start"
    || 'Table (2)'[Milestone] = "Start"
    || 'Table (2)'[Milestone] = "start1"
    ),
    "End_Time",
    CALCULATE (
    MIN ( 'Table (2)'[Date] ),
    'Table (2)'[Milestone] = "end"
    || 'Table (2)'[Milestone] = "End"
    || 'Table (2)'[Milestone] = "end1"
    )
    ),
    "Duration", DATEDIFF ( [Start_Time], [End_Time], YEAR )
    )

     


    Let me know if you have any questions.

    If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate your kudos!!

    • Anonymous2023's avatar
      Anonymous2023
      New Member

      Hi Thank you for your answer.
      Just a quick follow-up.
      In the original dataset, there is some milestone that is before the start date, which means that MIN does not apply. (I did not include that here for simplicity.)
      How should I proceed with this situation?
      Thank you.

      • NaveenGandhi's avatar
        NaveenGandhi
        Icon for Memorable Member rankMemorable Member

        Anonymous2023 

         

        Is that milestone a different category? If yes you can keep aggregating them as seperate columns same as how i have created start time and end time in the above measure.

         

        Regards,

        Naveen