Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
lancersc
Helper I
Helper I

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 IDCvP
A2024
A2023
B2024
C2024
C2023

 

(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 IDMatching
AMatched
BUnmatched
CMatched

 

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")

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

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:

vzhengdxumsft_0-1715568892052.png

 

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.

View solution in original post

4 REPLIES 4
v-zhengdxu-msft
Community Support
Community Support

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:

vzhengdxumsft_0-1715568892052.png

 

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.

_AAndrade
Super User
Super User

Hi @lancersc,

Could you provide a sample table with some data that represents your model, so I can take a look?





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Well, this is the only thing I am allowed to share rn. Not sure if it is any help.
On the left side of the Item ID should be the Matched/Unmatched.

lancersc_0-1715349648593.png

Where is this column  "CC vs PP" and their data? 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.