Forum Discussion
DAX IF statement for 2 filtered columns
Hello!
So its been about 1 week and I can't seem to figure out how to do this and I just give up.
I just want to compare 1 column filtered twice and probably beyond that after I make sense of this.
Table Example
| Item ID | CvP |
| A | 2024 |
| A | 2023 |
| B | 2024 |
| C | 2024 |
| C | 2023 |
(Item ID where CvP = 2024) = (Item ID where CvP = 2023)
If true = Matched, Else = Unmatched
A is matched
B is unmatched because it didn't exist last 2023
C is matched
Desired Result
| Item ID | Matching |
| A | Matched |
| B | Unmatched |
| C | Matched |
Below is what I used on DAX
RD Filter =
IF(
(CALCULATE(
SUM('RAW DATA (INVOICE)'[Item ID]),'RAW DATA (INVOICE)'[CC vs PP] = "2024"))
=
(CALCULATE(
SUM('RAW DATA (INVOICE)'[Item ID]),'RAW DATA (INVOICE)'[CC vs PP] = "2023"))
, "Matched","Unmatched")
- Anonymous2 years ago
Hi lancersc
Thanks for the reply from _AAndrade, please allow me to provide another insight:
Here I create a measure:
RD Filter = VAR _currentID = SELECTEDVALUE ( 'RAW DATA (INVOICE)'[Item ID] ) RETURN IF ( CALCULATE ( SELECTEDVALUE ( 'RAW DATA (INVOICE)'[Item ID] ), FILTER ( ALLSELECTED ( 'RAW DATA (INVOICE)' ), 'RAW DATA (INVOICE)'[Item ID] = _currentID && 'RAW DATA (INVOICE)'[CvP] = 2024 ) ) = CALCULATE ( SELECTEDVALUE ( 'RAW DATA (INVOICE)'[Item ID] ), FILTER ( ALLSELECTED ( 'RAW DATA (INVOICE)' ), 'RAW DATA (INVOICE)'[Item ID] = _currentID && 'RAW DATA (INVOICE)'[CvP] = 2023 ) ), "Matched", "Unmatched" )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- AnonymousNot applicable
Hi lancersc
Thanks for the reply from _AAndrade, please allow me to provide another insight:
Here I create a measure:
RD Filter = VAR _currentID = SELECTEDVALUE ( 'RAW DATA (INVOICE)'[Item ID] ) RETURN IF ( CALCULATE ( SELECTEDVALUE ( 'RAW DATA (INVOICE)'[Item ID] ), FILTER ( ALLSELECTED ( 'RAW DATA (INVOICE)' ), 'RAW DATA (INVOICE)'[Item ID] = _currentID && 'RAW DATA (INVOICE)'[CvP] = 2024 ) ) = CALCULATE ( SELECTEDVALUE ( 'RAW DATA (INVOICE)'[Item ID] ), FILTER ( ALLSELECTED ( 'RAW DATA (INVOICE)' ), 'RAW DATA (INVOICE)'[Item ID] = _currentID && 'RAW DATA (INVOICE)'[CvP] = 2023 ) ), "Matched", "Unmatched" )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.