Forum Discussion
Comparing Difference between two columns in two different tables
- 3 years ago
Hi Anonymous
Please create a dimension table that contains all ticket numbers. This can be created in power query or can be a calculated table using the following dax
Tickets =
DISTINCT (
UNION (
ALLNOBLANKROW ( Table1[Ticket Num] ),
ALLNOBLANKROW ( Table2[Ticket Num] )
)
)
then you apply the following measureDifference =
COALESCE (
SUMX (
VALUES ( Tickets[Ticket Num] ),
CALCULATE (
VAR Val1 =
SUM ( Table1[Value] )
VAR Val2 =
SUM ( Table1[Value] )
RETURN
IF ( Val1 <> BLANK () && Val2 <> BLANK (), Val2 - Val1 )
)
),
"No Match"
)
Hi Anonymous
First we need to create a relationship between the two tables, common Column is Tikcket number.
Second, we match the values or ticket numbers by creating calculated column so
Third we Calculate the difference =
Finally Create your table so
M4, Volume from table 1, volume from table 2, M3.
I hope this helps and please check the answer if it is right
- Anonymous3 years agoNot applicable
Hey Galaamri, thank you for being willing to help. I do believe this would be the solution if I could get the relationship to work.
When creating m4, I get the error "The column 'table 2 [ticket number]' either doesn't exist or doesn't have a relationship to any table available in the current context".
Extra info in case any of these help with solving the errors:
-I am attempting to create the calculated column column inside of table 1
-The ticket numbers from table 1 and table 2 will not match, a lot will but a lot will not. Some also include characters instead of just numbers. Both ticket columns are data type "text".
-When creating a relationship between the two before attempting to create m4, it makes a "many to many" relationship".- galaamri3 years agoHelper I
Then there is other way to make this relationship works by creating a reference table (to just have the unique ticket numbers). to do this:
Go to Power Query (Transform data), home, manage, then choose referece. you are creating a reference table1 based on the ticket number. then remove duplicate. then do the same for table2.
Connect the reference table1 and table1 (This should have one to many relationship), and the mesaure would work.
Regards
- Anonymous3 years agoNot applicable
Unfortunately it is still many to many relationship (I assume due to Table 1 will have ticket numbers table 2 doesn't have, and vice versa). But I am not entirely sure of the cause. But I do really appreciate the help.