Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Title: "Comparing Test Cases Between Different Versions in Power BI"

I have a dataset with two columns: "Test Case" and "Version." Different versions can contain the same or different test cases. In Power BI, I've created a matrix to display test cases for differen...
  • Sergii24's avatar
    Sergii24
    2 years ago

    Hi Anonymous, try this approach:

    Test Case Status = 
    VAR _CurrentTestCase = SELECTEDVALUE( 'Table'[Test Case] )                      //obtain TestCase from current row
    VAR _CurrentVersion = SELECTEDVALUE( 'Table'[Version] )                         //obtain version of currently selected TestCase
    VAR _VersionToCompare = SELECTEDVALUE( 'Compare version'[Version] )             //obtain a version you want to compare to
    
    VAR _CurrentTestCaseALL =                                                       //let's get all unique values of the version of the currently selected TestCase. It will be used to make comparison of item presence in prev version
        CALCULATETABLE(
            VALUES( 'Table'[Test Case] ),
            REMOVEFILTERS( 'Table'[Version], 'Table'[Test Case] ),                  //remove any filters applied on 'Table' 
            'Table'[Version] = _CurrentVersion
        )
    VAR _ToCompareTestCaseALL =                                                     //now let's get all possible unique values of TestCase we want to compare to 
        CALCULATETABLE(
            VALUES( 'Table'[Test Case] ),
            REMOVEFILTERS( 'Table'[Version], 'Table'[Test Case] ),                  //remove any filters applied on 'Table' 
            'Table'[Version] = _VersionToCompare
        )
    
    VAR _CommonRows = INTERSECT( _ToCompareTestCaseALL, _CurrentTestCaseALL )       //returns only rows present in both versions
    VAR _NewRows = EXCEPT( _CurrentTestCaseALL, _ToCompareTestCaseALL )             //get only new rows, i.e. present with TestCase of ToCompare version
    
    VAR _Result =
        IF(
            _CurrentTestCase in _NewRows,
            "New in " & _CurrentVersion,
            "Present in " & _VersionToCompare
        )
    RETURN _Result

     


    Make sure to turn on single select for filters and create a disconnected table with version values:

     

    Good luck! 🙂