Forum Discussion
abaulo
4 years agoFrequent Visitor
Calculate running backlog based on two fact tables
Hello everyone! I'm still getting my bearings with DAX and Data Modeling, so I'm unsure how to phrase the question. I've tried wording it many ways to find an existing solution to no avail. Even if...
- 4 years ago
Greg_Deckler , thanks for the tips!
I used CONCATENATEX to figure out what was happening in each CALCULATETABLE. I eventually got the following to work, though I'm still not entirely sure why I have to include ALL in each CALCULATETABLE, which leads me to believe there's probably a more elegant solution.
Backlog = var MaxDate = //Get the latest date from the Week of Year context MAX('Calendar'[Date]) var TemplatedJobs = //Get JobIDs of Templated Jobs thus far CALCULATETABLE( SUMMARIZE( Template, Job_Info[JobID] ), Template[Template Date] <= MaxDate, ALL(Template) ) var InstalledJobs = //Get JobIDs of Installed Jobs thus far CALCULATETABLE( SUMMARIZE( Install, Job_Info[JobID] ), Install[Install Date] <= MaxDate, ALL(Install) ) var Backlog = //Get JobIDs of jobs that have been Templated but not Installed EXCEPT( TemplatedJobs, InstalledJobs ) Return //Sum the Sqft of those jobs CALCULATE( [Templated Footage], //= SUM(Template[SqFt]) Template[JobID] IN Backlog, ALL(Template) )
abaulo
4 years agoFrequent Visitor
Greg_Deckler , thanks for the tips!
I used CONCATENATEX to figure out what was happening in each CALCULATETABLE. I eventually got the following to work, though I'm still not entirely sure why I have to include ALL in each CALCULATETABLE, which leads me to believe there's probably a more elegant solution.
Backlog =
var MaxDate = //Get the latest date from the Week of Year context
MAX('Calendar'[Date])
var TemplatedJobs = //Get JobIDs of Templated Jobs thus far
CALCULATETABLE(
SUMMARIZE(
Template,
Job_Info[JobID]
),
Template[Template Date] <= MaxDate,
ALL(Template)
)
var InstalledJobs = //Get JobIDs of Installed Jobs thus far
CALCULATETABLE(
SUMMARIZE(
Install,
Job_Info[JobID]
),
Install[Install Date] <= MaxDate,
ALL(Install)
)
var Backlog = //Get JobIDs of jobs that have been Templated but not Installed
EXCEPT(
TemplatedJobs,
InstalledJobs
)
Return //Sum the Sqft of those jobs
CALCULATE(
[Templated Footage], //= SUM(Template[SqFt])
Template[JobID] IN Backlog,
ALL(Template)
)