Forum Discussion

Spencer_Bye's avatar
Spencer_Bye
Frequent Visitor
2 years ago
Solved

Conditional Relationship between Tables

Currently, I am working with a data set that tracks work order requests. The data is stored in two seperate tables. One is the current status of all of our work orders past and present. It includes a...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Spencer_Bye ,

    You can follow the steps below to get it:

    1. Create a measure as below

    Flag =
    VAR _hisdate =
        SELECTEDVALUE ( 'HistoricTable'[Date] )
    VAR _wknum1 =
        SELECTEDVALUE ( 'CurrentStatusTable'[WorkOrder Number] )
    VAR _wknum2 =
        CALCULATE (
            MAX ( 'CurrentStatusTable'[WorkOrder Number] ),
            FILTER (
                'CurrentStatusTable',
                'CurrentStatusTable'[WorkOrder Number] = _wknum1
                    && 'CurrentStatusTable'[Date_Created] <= _hisdate
                    && (
                        ISBLANK ( 'CurrentStatusTable'[Date_Completed] )
                            || 'CurrentStatusTable'[Date_Completed] >= _hisdate
                    )
            )
        )
    RETURN
        IF ( ISBLANK ( _wknum2 ), 0, 1 )

    2. Apply a visual-level filter on your matrix visual with the condition (Flag is 1)

    Best Regards