Forum Discussion

SCallanan's avatar
SCallanan
Frequent Visitor
2 years ago
Solved

Filter and Replace values

Hi guys,   I want to filter and replace the SUM of the Distinctcount values  when Admin & physical both apply together and replace the total which would be 2 with 1.    Please note, this is only ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, SCallanan 

    I am glad to help you.

    But I am not sure if I have understood your needs correctly.


    Perhaps you could start by trying to create a calculated column that marks each Trip Inspection Id as having both "Administrative" and "Physical":

    HasBoth = 
    VAR CurrentTripId = Inspections[Trip Inspection Id]
    RETURN
        IF (
            CALCULATE (
                COUNTROWS ( Inspections ),
                Inspections[Trip Inspection Id] = CurrentTripId,
                Inspections[Inspection Group] = "Administrative"
            ) > 0
                && CALCULATE (
                    COUNTROWS ( Inspections ),
                    Inspections[Trip Inspection Id] = CurrentTripId,
                    Inspections[Inspection Group] = "Physical"
                ) > 0,
            1,
            0
        )
    


    Then create a Measure:

    TripInspectionIdCount = 
    CALCULATE (
        DISTINCTCOUNT ( Inspections[Trip Inspection Id] ),
        Inspections[HasBoth] = 1
    )
        + CALCULATE (
            DISTINCTCOUNT ( Inspections[Trip Inspection Id] ),
            Inspections[HasBoth] = 0
        )
    


    Here is the final test result, hope it helps:

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.