Forum Discussion
Comparing between different filters on the same data
- 8 years ago
Hi olik,
You can try the below method as well!!! FYI, I have the data that you have provided for this purpose
The Following are the steps.
1. Have 2 copies of your data (namely Table1 and Table2)
2. Join the tables based on Date Column
3. Create the following 2 measures
In Table1
Measure 1 = CALCULATE(SUM(Table1[Value]), FILTER(Table1, Table1[Account] = SELECTEDVALUE(Table1[Account])))
In Table2
Measure 2 = CALCULATE(SUM(Table2[Value]), FILTER(Table2, Table2[Account] = SELECTEDVALUE(Table2[Account])))
Create another measure to find the difference between the measures
Measure = [Measure 1] - [Measure 2]
Relationship, more likely to look like (not necessarily have to be same)
Relationship between tables through a bridge table
My Output looked as shown below
Output
As you change the accounts in your slicer, you value changes correspondingly....
Hope this helps you get what you needed!!!
regards,
Thejeswar
- 8 years ago
Thanks a lot! I used your suggestion and made the formula even easier:
Result = SUM(Table1[Value]) - CALCULATE(SUM(Table1[Value]), FILTER(ALL(Table1[Account]),Table1[Account] = SELECTEDVALUE(Table2[Account])))
That way I only need one measure, and technically I don't even need the full duplicate table... Just another list of accounts would do!
Do you see any issues with my approach? Still very new to the whole DAX coding!
Thanks a lot! I used your suggestion and made the formula even easier:
Result = SUM(Table1[Value]) - CALCULATE(SUM(Table1[Value]), FILTER(ALL(Table1[Account]),Table1[Account] = SELECTEDVALUE(Table2[Account])))
That way I only need one measure, and technically I don't even need the full duplicate table... Just another list of accounts would do!
Do you see any issues with my approach? Still very new to the whole DAX coding!