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
1984
Frequent Visitor

DAX LOOKUP IF AND COUNT

Hi 

 

I've been away from DAX for some time and trying to create a column with a calculation.

 

I have two tables with a 1:many relationship.

I would like to create a column in Table 1 (1 side) that lookup in table 2 at how many rows for each ID have the status "Complete" in the status column contained in table 2?

 

Like I say new returner so probably a simple fix pls be kind 🙂

 

 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Read about RELATEDTABLE. That allows you to look into the "many"  side of a relationship.

View solution in original post

v-kaiyue-msft
Community Support
Community Support

Hi @1984 ,

I want to acknowledge valuable input provided by @lbendlin . Their initial ideas help guide my approach. However, I noticed that more details are needed to fully understand this issue.


I created two tables and created a one-to-many relationship for them.

vkaiyuemsft_0-1714117119799.png


Create a calculated column in the "table" table for counting.

StatusCount =
VAR_count=
CALCULATE(
COUNTROWS('Table 2'),
RELATEDTABLE('Table 2'),
'Table 2'[status] = "Complete"
)
RETURN
IF(_count = BLANK(),0,_count)

vkaiyuemsft_1-1714117146303.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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-kaiyue-msft
Community Support
Community Support

Hi @1984 ,

I want to acknowledge valuable input provided by @lbendlin . Their initial ideas help guide my approach. However, I noticed that more details are needed to fully understand this issue.


I created two tables and created a one-to-many relationship for them.

vkaiyuemsft_0-1714117119799.png


Create a calculated column in the "table" table for counting.

StatusCount =
VAR_count=
CALCULATE(
COUNTROWS('Table 2'),
RELATEDTABLE('Table 2'),
'Table 2'[status] = "Complete"
)
RETURN
IF(_count = BLANK(),0,_count)

vkaiyuemsft_1-1714117146303.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

lbendlin
Super User
Super User

Read about RELATEDTABLE. That allows you to look into the "many"  side of a relationship.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.