Forum Discussion

bombom's avatar
bombom
Icon for Helper I rankHelper I
3 years ago

Power BI count distinct IDs with a condition

I have a data that looks like this:


DateTicketIdStepResult
01.01.2020 13:00:001234562Successfull
01.01.2020 13:00:001234564Successfull
01.01.2020 13:00:051234568Error
01.01.2020 13:05:001234562Successfull
01.01.2020 13:05:001234564Successfull
01.01.2020 13:05:051234568Error
01.01.2020 13:10:001234562Successfull
01.01.2020 13:10:001234564Successfull
01.01.2020 13:10:051234568Error
01.01.2020 13:15:001234562Successfull
01.01.2020 13:15:001234564Successfull
01.01.2020 13:05:006543212Successfull
01.01.2020 13:05:006543214Successfull
01.01.2020 13:05:056543218Error
01.01.2020 13:10:006543212Successfull
01.01.2020 13:10:006543214Successfull
01.01.2020 13:10:056543218Error
01.01.2020 13:15:006543212Successfull
01.01.2020 13:15:006543214Successfull
01.01.2020 13:10:000987652Successfull
01.01.2020 13:10:000987654Successfull
01.01.2020 13:10:050987658Error
01.01.2020 13:10:000987652Successfull
01.01.2020 13:10:000987654Successfull
01.01.2020 13:10:050987658Error

 

From that data I have a matrix that calculates the distinct quantity of TicketIDs that have a step = 8 (Result = 'Error').

 

I need a DAX measure to calculate distinct number of TicketIDs if the TicketID have the Result = 'Successfull' as a last, before he had a Result = 'Error'. Note that next I will need to drillthrogh through the mesaure up to found TicketId.

Example of the desired output:


DateCount_distinct_TickedId_with_ErrorsCount_distinct_TickedId_with_Successfull_and_Errors_before
01.01.202032

 

It's a 123456 and 654321 TickedIds.

 

Current DAX measure to calculate distinct TickedIds with errors looks like this:

  1. LogDistcount_ = DISTINCTCOUNT(Logging[TicketId])
  2. Errors_dist = CALCULATE(Logging[LogDistcount_], Logging[Step] = 😎

And also, if it's not hard, the measure to calculate the TickedId, which is still have an Error result as at last.


DateCount_distinct_TickedId_with_ErrorsCount_distinct_TickedId_with_Successfull_and_Errors_beforeCount_distinct_TickedId_with_Errors_still
01.01.2020321

 

It's a 098765.

 

Many thanks!

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bombom ,

     

    Depending on your requirements, you want to implement a measure [calculate distinct number of TicketIDs if the TicketID have the Result = 'Successfull' as a last], but I didn't fully understand the logic you want to output after looking at your Example of the desired output.

    If it is convenient, can you write your Example of the desired output and populate it in the reply so that we can fully understand your needs?

     

    Best Regards,

    Neeko Tang

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