Forum Discussion

Alan_GA's avatar
Alan_GA
Frequent Visitor
1 year ago
Solved

Filtering data by a visual is incorrect - Context issue

Hello, im new in power bi. I have a visual that shows a count of IDs for each status ("In process", "Pending", "Cancelled", etc.) using a measure, and below that, I have a table with an ID colum...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Alan_GA ,

     

    I think your issue is caused by that the [ID] column will be filtered by date. So it will only show ID in date range.

    Here I suggest you to create an unrelated ID table to help calculation.

    DimID = 
    VALUES(Sheet1[ID])

    Measure:

    Measure = 
    VAR _IDListbyDate =
        VALUES ( Sheet1[ID] )
    VAR _FinishList =
        CALCULATETABLE ( VALUES ( Sheet1[ID] ), Sheet1[Status] = "Finished" )
    VAR _InprocessList =
        CALCULATETABLE (
            VALUES ( Sheet1[ID] ),
            REMOVEFILTERS ( Sheet1[Date] ),
            Sheet1[Status] = "In process"
        )
    RETURN
        IF (
            ISFILTERED ( Sheet1[Status] ),
            SWITCH (
                SELECTEDVALUE ( Sheet1[Status] ),
                "In process", IF ( MAX ( DimID[ID] ) IN _InprocessList, 1, 0 ),
                "Finished", IF ( MAX ( DimID[ID] ) IN _FinishList, 1, 0 )
            ),
            IF ( MAX ( DimID[ID] ) IN _IDListbyDate, 1, 0 )
        )

    You can create a table visual by this ID column, then add measure into visual level filter and set it to show items when value =1.

    Result is as below.

    By Default:

    Click on "In process"

    Click on "Finished"

     

    Best Regards,
    Rico Zhou

     

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