Forum Discussion
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 different versions side by side.
- I also have a slicer that allows users to select two versions for comparison.
- Let's say Version 1.1 is the older version, and Version 1.2 is the newer one.
- I want to know how to:
- Generate a table or use another method to display a list of test cases that have been removed from Version 1.2 compared to Version 1.1.
- Generate a table or use another method to display a list of test cases that have been added to Version 1.2.
- Generate a table or use another method to display a list of test cases that are common to both Version 1.1 and Version 1.2.
here is my current solution but the list it return can not be displayed in a table, only showing as a string list can be displayed as a value in a matrix table.
| Test Case | Version |
| A1.1 | Version 1.1 |
| A1.2 | Version 1.1 |
| A1.3 | Version 1.2 |
| A1.2 | Version 1.2 |
| A1.1 | Version 1.3 |
| A1.6 | Version 1.3 |
| A1.2 | Version 1.3 |
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! 🙂
4 Replies
- AnonymousNot applicable
Hi Anonymous ,
Please have a try.
RemovedTestCasesPercentage = VAR SelectedVersionA = "Version 1.1" VAR SelectedVersionB = "Version 1.2" VAR TotalTestCases = COUNTROWS ( VALUES ( data[Test Case] ) ) VAR RemovedTestCases = COUNTROWS ( EXCEPT ( CALCULATETABLE ( VALUES ( data[Test Case] ), data[Version] = SelectedVersionA ), CALCULATETABLE ( VALUES ( data[Test Case] ), data[Version] = SelectedVersionB ) ) ) RETURN DIVIDE ( RemovedTestCases, TotalTestCases )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Thanks, Rongtie,
I want to display a list of removed items in a table, not the percentage of removed test cases. also the 2 selectedVersion values are not fixed value, they should be any 2 values that the user selects from a version slicer.
- Sergii24
Super User
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! 🙂