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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
QQ
Frequent Visitor

Calculate on two fact tables linked to same dimension tables

 

Your help highly appreciated!

 

I have two fact tables: fct_Case and fct_Client

fct_Case
CaseID
ClientID
Date
Group

 

fct_Client
ClientID
QuarterDate
Active
Group

 

And 3 dimension tables which the fact tables are linked to.

dim_Date
Date
Quarter

 linked to the fact tables by [Date] column

 

dim_Group
Group

 

linked to the fact tables by [Group] column

 

dim_Client ID
Client ID

 

linked to the fact  tables by [Client ID] column

 

I need to calculate on the numbers of cases where the clients are active in one specific quarter. Here is the measure I generate:

= calculate(distintcount(fct_Case[CaseID]), filter(fct_Client, fct_Client[Active]="Y"), DatesBetween(fct_Case[Date],Date1, Date2))

 

This measure works if dim_Group and dim_Date are removed. However it gives wrong value with these two dimension tables included. 

 

I understand this is due to the multple possible links between the two fact tables. I tried to add Userelationship into the measure but it does not work either. 

 

Any possible solution to generate a measure to solve the issue? Thanks a lot!

6 REPLIES 6
bdymit
Resolver II
Resolver II

You are trying to have a filter that you are putting on one fact table affect your other fact table.

 

The problem is that fact tables can only be affected by filters on themselves or by filters on dimensional tables related to them.

 

In other words, your relationships between tables are "one to many" relationships (unless you have a more complicated data model with bi-directional filtering, in which case you should make that known). A filter on a dimensional table (the "one" side of the relationship) filters your fact table as well (the fact table is the "many" side of the relationship.)

 

A filter on your fact table will not affect your dimensional table.

 

I am experimenting with a some ideas, but I am wondering, what is the relationship between fct_Client and dim_Date?

 

If fct_Client[QuarterDate] related to dim_Date[Date]? Or do you have it somehow related to dim_Date[Quarter]?

Also, is Group an identifier for ClientID?

 

Such that each ClientID belongs to one group?

 

Thanks!

QQ
Frequent Visitor

Group and ClientID are many to many relationship as well, one group have multiple ClientIDs and one ClientID can have multiple groups.

 

The fct_Client table records are at quarterly Client level. It looks like:

ClientIDQuarterDateActive Group
101-01-2010YesA
101-04-2010YesA
101-07-2010NoA
101-10-2010YesB
101-01-2011YesB
101-04-2011YesB
201-01-2010NoC
201-04-2010NoC
201-07-2010YesA
201-10-2010YesA
201-01-2011YesA
201-04-2011YesA

 

The [QuarterDate] is linked to [Date] in the dim_Date table. 

 

Thanks!

Hi @QQ,

 

Could you try to replace fct_Case[Date] with dim_Date[Date] in measure formula?

Measure= calculate(distintcount(fct_Case[CaseID]), filter(fct_Client, fct_Client[Active]="Y"), DatesBetween(dim_Date[Date],Date1, Date2))

 

Also, what is the detailed data in fct_Case table?

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Just tried and unfortunately not working. But thanks a lot Yuliana!

 

I think I may have to change the data model and not filter the fact table but put [Active] into one of the dimension table so I can filter on the dimension table.

 

Thank you all for your help!

Qing

Hi @QQ,

 

Thanks for your sharing. 

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.