DAX / PowerPivot cross-join type of query spread to unsummarize/de-aggregate data

1k Views Asked by At

So, I have an extension to the question I asked here a while ago (ref: DAX / PowerPivot query functions to spread aggregated values over time period ), which I’ve been beating my head against the wall on.

I’ve got the same general data (the output of a MS Project export) that has tasks, durations, assignments, etc. Tasks have been categorized against which project/application they relate to & I’m able to do that spread of hours over time without issue. Where the problem lies is in spreading values from a custom field across all others.

Example output from the existing pivot:

Current Output Table

What I’m trying to get to is having everything from “ALL” spread the hours evenly across all of the other Related_Applications - there are about 20, and there is a table for them, so I would use a COUNTROWS().

Using the above as the example, what I’m trying to get to is having it so that the hours (and Name) for each of the ALL show up in each of the Related_Applications. E.g. Information Assurance and Security in Month 2 of 2015 should be spread by hours / countrows(all(related_applications)). Similarly, if you were to use the Systems Administrator values, they’d need spread & added to the existing row value. The target output of the DAX would be something like a CrossJoin and end up like this:

Desired Output Table

I keep thinking I’m close, and added a dummy table for “SpreadValuesSheet” to use the ALLEXCEPT and ALL functions. It contains the values that should spread (currently have 3x … ALL, PM and CM). I have another table for “ApplicationsSheet” that has the 30x or so apps that the hours there should spread to.

The data model @ current is set up like so:

Data Model

I can get the pieces individually; but can’t seem to get the measure back into the AssignmentsSheet to work (so I can have the time spread, filters by resources, etc.) … I managed that with the definitions of the calculated columns and measures below:

AssignmentsSheet:

MeasureSumScheduledWork:=sum([Scheduled_Work])
Hours Apportioned Raw:=DIVIDE (
    CALCULATE (
                [MeasureSumScheduledWork],
                FILTER (
                    AssignmentsSheet,
                    AssignmentsSheet[Start_Date] <= MAX ( DateSheet[Date] )
                        && AssignmentsSheet[Finish_Date] >= MAX ( DateSheet[Date] )
                        )
                )
    , ( COUNTROWS(DATESBETWEEN ( DateSheet[Date], FIRSTDATE ( AssignmentsSheet[Start_Date] ), LASTDATE ( AssignmentsSheet[Finish_Date] ))))
)

SpreadHoursMeasure:=SUMX (
    VALUES ( DateSheet[Date] ),
    SUMX ( VALUES ( AssignmentsSheet[Index] ), [Hours Apportioned RAW] )
)

Which works perfectly. Trying to spread out the others, I start running into issues. I currently am stuck with the following measures:

UFSpreadHoursMeasure:=CALCULATE(
SUMX (
    VALUES ( DateSheet[Date] ),
    SUMX( VALUES ( AssignmentsSheet[Index]), [Hours Apportioned Raw])
), RELATEDTABLE(SpreadValuesSheet))

SpreadAllValuesMeasure:=[SpreadHoursMeasure]+CALCULATE([UFSpreadHoursMeasure],all(ApplicationsSheet))

SpreadValuesSheet:

Calculated Column: 
SumHours =[SpreadHoursMeasure]
MeasureSpreadHours:=sum([SumHours])

ApplicationsSheet

Calculated Columns:
SumHours=[SpreadHoursMeasure]
SpreadHours=[MeasureSpreadHours]/COUNTROWS(ApplicationsSheet)
TotalHours==[SumHours]+[SpreadHours]
MeasureSpreadSumTotalHours:=sum([TotalHours])
0

There are 0 best solutions below