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! Learn more

Reply
Anonymous
Not applicable

Calculate measures on the basis of 2 related tables but ignoring this relationship?

Hi everyone!

 

I have 2 tables: one table is a fact table containing dates field and the number of events, another table is a dimension table containing names and dates of creating these names. These tables are related by the field id_n, but I need calculate measure that will calculate the number of names (from table 2) per each date (from table 1) where created_date (from table 2) is greater than or equal to date (from table 1). 

 

The formula should looks like measure_table_1 = COUNT( IF(table_2[created_date] > = table_1[date], table_2[id_n]) )

 

Screenshot 2021-05-07 110057.png

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below, please find the details in the attachment.

Count of names = 
CALCULATE (
    DISTINCTCOUNT ( 'Table 2'[name_id] ),
    FILTER (
        ALL('Table 2'),
        'Table 2'[create_date] >= SELECTEDVALUE ( 'Table 1'[date] )
    )
)

yingyinr_1-1620723092415.png

Best Regards

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Try like

measure_table_1 = calculate(COUNTX(table_2, IF(table_2[created_date] > = max(table_1[date]), table_2[id_n],blank()) ),values(table_2[id_n]), crossfilter(table_2[id_n],table_1[id_n], none))

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
Anonymous
Not applicable

Hi. Thanks for the answer. But is it possible to do calculation without creating a new table?

 

Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below, please find the details in the attachment.

Count of names = 
CALCULATE (
    DISTINCTCOUNT ( 'Table 2'[name_id] ),
    FILTER (
        ALL('Table 2'),
        'Table 2'[create_date] >= SELECTEDVALUE ( 'Table 1'[date] )
    )
)

yingyinr_1-1620723092415.png

Best Regards

Anonymous
Not applicable

Thank you very much!

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