Forum Discussion
BM4291
3 years agoResolver I
Filtering across multiple tables and relationships
Hi, Struggling to make some sense of a few measures and hoping someone might be able to see the wood for the trees on this! Problem I have three fact tables and a dimension table, I need to ...
- 3 years ago
lbendlin Anonymous Apologies for the delay, it has been a busy few days and this went on the backburner; I had to use the SQL version to get the data across but have re-visited and got the answer... I don't think this is necessarily the most performant, and there may be a better way to reach the conclusion but see below:
MEASURE Hearings[hearingsClosedCaseX] = //Hearings that appear on Cases Closed with X with Hearings COUNTROWS( DISTINCT( NATURALINNERJOIN( CALCULATETABLE( TREATAS( SELECTCOLUMNS( FILTER(Applications , [AppType] = X ) , "CaseID", [CaseID] ) , Hearings[CaseID] ) , USERELATIONSHIP(Dates[Date], 'Case'[CaseClosed]) ) , CALCULATETABLE(Hearings, USERELATIONSHIP(Dates[Date], 'Case'[CaseClosed])) ) ) ) MEASURE Hearings[hearingsCasesClosedX] = //Cases Closed with a X with Hearings COUNTROWS( DISTINCT( CALCULATETABLE( TREATAS( SELECTCOLUMNS( FILTER(Applications , [AppType] = X ) , "CaseID", [CaseID] ) , Hearings[CaseID] ) , USERELATIONSHIP(Dates[Date], 'Case'[CaseClosed]) ) ) )
BM4291
3 years agoResolver I
lbendlin Anonymous Apologies for the delay, it has been a busy few days and this went on the backburner; I had to use the SQL version to get the data across but have re-visited and got the answer... I don't think this is necessarily the most performant, and there may be a better way to reach the conclusion but see below:
MEASURE Hearings[hearingsClosedCaseX] =
//Hearings that appear on Cases Closed with X with Hearings
COUNTROWS(
DISTINCT(
NATURALINNERJOIN(
CALCULATETABLE(
TREATAS(
SELECTCOLUMNS(
FILTER(Applications
, [AppType] = X
)
, "CaseID", [CaseID]
)
, Hearings[CaseID]
)
, USERELATIONSHIP(Dates[Date], 'Case'[CaseClosed])
)
, CALCULATETABLE(Hearings, USERELATIONSHIP(Dates[Date], 'Case'[CaseClosed]))
)
)
)
MEASURE Hearings[hearingsCasesClosedX] =
//Cases Closed with a X with Hearings
COUNTROWS(
DISTINCT(
CALCULATETABLE(
TREATAS(
SELECTCOLUMNS(
FILTER(Applications
, [AppType] = X
)
, "CaseID", [CaseID]
)
, Hearings[CaseID]
)
, USERELATIONSHIP(Dates[Date], 'Case'[CaseClosed])
)
)
)