Forum Discussion

IvanS's avatar
IvanS
Icon for Helper V rankHelper V
3 years ago
Solved

Compare 2 columns from different tables without relationship

Hi guys,

 

I have small problem with performing DAX calculation between 2 tables that have no active relationship.

 

Here is example tables with the red highlighted column:

Table: FACT_Tasks

ID (unique values)RelatedTo_ID (Task can be related to several tables - such as Case, Product, Location)
1111
1123
1135
1141
1158

 

Table: FACT_Cases

ID (unique values)Nr. of tasks (calculated column)
12
20
31

 

I tried following function but it is taking previous Case ID and I am not aware how to compare it with the current row.

 

CALCULATE(
    COUNT(FACT_Tasks[Id]), FACT_Tasks[RelatedTo_Id] = EARLIER(FACT_Cases[Id]))

 

 

Any help is much appreciated!

Thank you

Ivan

  • IvanS , a new column in FACT_Cases

    CALCULATE(
        COUNT(FACT_Tasks[Id]),filter(FACT_Tasks, FACT_Tasks[RelatedTo_Id] = FACT_Cases[Id]))

     

1 Reply

  • IvanS , a new column in FACT_Cases

    CALCULATE(
        COUNT(FACT_Tasks[Id]),filter(FACT_Tasks, FACT_Tasks[RelatedTo_Id] = FACT_Cases[Id]))