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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
thomasgcoelho
Frequent Visitor

Simple "FILTER" and "IF" on multiple matching rows

Hello! I'm trying to create a new column that checks if certain information has a match in another table, but I'm failing because my reference column matches more than once.

 

I have an "Inspections Table", like this:

MonthInspection LeaderInspected Location
SeptemberAlbertFront yard
SeptemberBernardBack yard
OctoberCromwellFront yard
OctoberBernardBack yard
DecemberCromwellWest yard

 

And a "Planning Table", like this:

MonthPlanned LocationPlanned Leader
SeptemberFront yardAlbert
SeptemberBack yardCromwell
OctoberWest yardCromwell
OctoberFront yardBernard
DecemberWest yardDennis
DecemberBack yardBernard

 

I'm trying to create two columns at the end of the "Inspections Table" like these:

MonthInspection LeaderInspected LocationSame Leader as planned for the month?Same Location as planned for the month?
SeptemberAlbertFront yardYesYes
SeptemberBernardBack yardNoYes
OctoberCromwellFront yardYesYes
OctoberBernardBack yardYesNo
DecemberCromwellWest yardNoNo

 

I tried going for a FILTER with an IF in DAX, but I can't get it right. I think I'm having trouble with the fact that months may occur more than once in the "Planning Table".

 

Thanks in advance!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@thomasgcoelho 

I can get everything to match up except the December - West Yard I must be missing something.  It is in both your inspections and planning table, just with a different leader so I get a Yes for [Same Location as planned for the month?].  Anyway, here are the calculated columns using LOOKUPVALUE.

Same Leader as planned for the month? = 
IF (
    Inspections[Inspection Leader]
        = LOOKUPVALUE (
            Planning[Planned Leader],
            Planning[Month], Inspections[Month],
            Planning[Planned Leader], Inspections[Inspection Leader]
        ),
    "Yes",
    "No"
)
Same Location as planned for the month? = 
IF (
    Inspections[Inspected Location]
        = LOOKUPVALUE (
            Planning[Planned Location],
            Planning[Month], Inspections[Month],
            Planning[Planned Location],Inspections[Inspected Location]
        ),
    "Yes",
    "No"
)

jdbuchanan71_0-1630889546123.png

 

View solution in original post

2 REPLIES 2
thomasgcoelho
Frequent Visitor

Thank you @jdbuchanan71 ! Now I see where I messed up. Marked your reply as solution.

jdbuchanan71
Super User
Super User

@thomasgcoelho 

I can get everything to match up except the December - West Yard I must be missing something.  It is in both your inspections and planning table, just with a different leader so I get a Yes for [Same Location as planned for the month?].  Anyway, here are the calculated columns using LOOKUPVALUE.

Same Leader as planned for the month? = 
IF (
    Inspections[Inspection Leader]
        = LOOKUPVALUE (
            Planning[Planned Leader],
            Planning[Month], Inspections[Month],
            Planning[Planned Leader], Inspections[Inspection Leader]
        ),
    "Yes",
    "No"
)
Same Location as planned for the month? = 
IF (
    Inspections[Inspected Location]
        = LOOKUPVALUE (
            Planning[Planned Location],
            Planning[Month], Inspections[Month],
            Planning[Planned Location],Inspections[Inspected Location]
        ),
    "Yes",
    "No"
)

jdbuchanan71_0-1630889546123.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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