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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tanat_inc
Helper II
Helper II

Create column base on count of another table with some conditions

I have 2 table with below

tanat_inc_0-1683339169014.png


How should I add column to "fact_customer_profile" for visit_count_facebook ?  I have success with:

countrow(
  filter( fact_customer_visit, fact_customer_visit[cusotmer_id] = fact_customer[customer_id] && fact_customer_visit[mkt_channel] = "Facebook"
)

But it will count duplicate values as two. Also when I experiment to make it count distinct on visit_id, it always fails with infinite duration calculation.

1 ACCEPTED SOLUTION

I can make it with this code already :

countrows(
  summarize(  

    filter(

      fact_customer_visit,

      fact_customer_visit[cusotmer_id] = fact_customer[customer_id]

        && fact_customer_visit[mkt_channel] = "Facebook"

    ),

    fact_customer_visit[cusotmer_id],

    fact_customer_visit[mkt_channel]
)

 

It's adapt from the code provided by performance analyzer after did what you told me to do. Not sure if it's the best way or not, but thanks to the idea you provided.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Assuming the ID's in Table1 will never repeat, create a relationship (Many to One and Single) from Table2 to Table1.  To your visual, drag the fields from Table1.  Write this measure

Measure = distinctcount('Table2'[Employee ID])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Could you provide the code to add calculated column instead? 

Actual dataset is 3GB in size and I want to create multiple calculated column like this for customer segmentation purpose.

Hi,

Share data in a format that can be pasted in an MS Excel file and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I can make it with this code already :

countrows(
  summarize(  

    filter(

      fact_customer_visit,

      fact_customer_visit[cusotmer_id] = fact_customer[customer_id]

        && fact_customer_visit[mkt_channel] = "Facebook"

    ),

    fact_customer_visit[cusotmer_id],

    fact_customer_visit[mkt_channel]
)

 

It's adapt from the code provided by performance analyzer after did what you told me to do. Not sure if it's the best way or not, but thanks to the idea you provided.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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