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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply

Lookup Value based on a specific field

Hi - I am using the following formula to look up AD_Hosp_Number in the table 'Activity & Demand'.  I'm using the corresponding value in the Cancer Performance Data table as my lookup.

However, in the activity and demand table, there are event keys for both activity and demand, so I want to somehow find a way to only lookup the values which correspond only those rows which are activity.  An example of this is below.  So, you can see some of the event key values have both activity and demand, but I only want to lookup those relating to activity:

Event KeyA or D
15765116Activity
15765116Demand
10579661Demand
10579662Activity
16955865Activity
16955866Demand
17313760Activity
17412241Activity
17412242Demand

 

Hosp No? = LOOKUPVALUE('Activity & Demand'[AD_Hosp_Number], 'Activity & Demand'[AD_Event_Key],'Cancer Performance Data'[Event key], "Unknown")
 
Many thanks!
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Creative_tree88 

 

You can try the following methods.

 

Column = 
CALCULATE ( MAX ( 'Activity & Demand'[A or D] ),
    FILTER ( 'Activity & Demand',
        [Event Key] = EARLIER ( 'Cancer Performance Data'[Event Key] )
            && [A or D] = "Activity"
    )
)

 

vzhangti_0-1694424298747.png

Is this the result you expect? If not, please provide more details.

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Creative_tree88 

 

You can try the following methods.

 

Column = 
CALCULATE ( MAX ( 'Activity & Demand'[A or D] ),
    FILTER ( 'Activity & Demand',
        [Event Key] = EARLIER ( 'Cancer Performance Data'[Event Key] )
            && [A or D] = "Activity"
    )
)

 

vzhangti_0-1694424298747.png

Is this the result you expect? If not, please provide more details.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Creative_tree88 , Try a new column like

 

coalesce(
max(filter('Activity & Demand', 'Activity & Demand'[AD_Event_Key],'Cancer Performance Data'[Event key] ),'Activity & Demand'[AD_Hosp_Number]), "Unknown")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors