How to Create Graph for Concurrent Projects - sharepoint

I have a list of projects from SharePoint which has one column for Start Date, and one column for End Date. I would like to create a Power BI visual which plots for all dates in a calendar how many projects are currently being worked on.
I have done something similar to this in SAS, and even Excel, where I can just have an arbitrary number of columns, representing a date, and then create an if statement referencing that date which gives a binary value for whether or not that date is in the desired interval. Then I can add those up and plot the totals against the aforementioned dates. As far as I have been able to do, I cannot replicate this in Power BI. Is there some sort of functionality or custom visual I do not know of which could achieve this?

You can do the following using the following 'pseudo' code.
First create a New Table from the modeling tab and use the following code to create a small calendar table.
Calendar =
CALENDAR (
MIN ( Projects[StartDate] ) ,
MAX ( Projects[EndDate] )
)
Create a measure from the same menu as where you created the table and add the following code
ActiveProjects =
var _selectedDate = MIN ('Calendar'[Date] )
RETURN
CALCULATE (
COUNTROWS ( Projects ) ,
ALL ( Projects ) ,
Projects[StartDate] < _selectedDate ,
Projects[EndDate] >= _selectedDate
)
Then plot the Date field from your calendar table against the measure you've just created and create an area chart for instance.

Related

Power Pivot: Average by group using many-to-many table relationship

I have three tables in Power Pivot. Pupils, Baselines and Reports. The Pupils table connects to the Reports and Baselines tables via a One to Many relationship as shown below.
The Reports table has each pupil listed multiple times for each subject they have a report in. They are also listed multiple times in the Baselines table for each baseline score they have. What I want to accomplish is to create a measure that calculates the average baseline score in each subject. So take all pupils who have a maths report, I want to know the average baseline score in maths.
I tried the following measure:
Av Baseline:=AVERAGEX( CALCULATETABLE( Baselines, Baselines[Type] = "Overall" ), Baselines[Average] )
However the above when used in a pivot table produces the same result for all subjects, so the filter context is not being applied. I keep hearing people using bridge tables, which does add a ton of data and are not very efficient so I hope to avoid those if at all possible.
I have provided some example data with the desired output table, hope that helps?
Could you please test this:
Note: I hope Your Pupils table has a column called [Subject Code] It is not clear from your shared data.
Version - 1
Av Baseline :=
AVERAGEX (
VALUES ( Pupils[Subject Code] ),
CALCULATE (
SUM ( Baselines[Average] ),
CALCULATETABLE ( Baselines, Baselines[Type] = "Overall" )
)
)
Version - 2
Av Baseline =
VAR Combin =
SUMMARIZE (
Baselines,
Baselines[Type],
Pupils[Subject Code],
Baselines[Result]
)
VAR Combinfiltered =
FILTER ( Combin, Baselines[Type] = "Overall" )
VAR Result =
CALCULATE ( AVERAGE ( Baselines[Result] ), Combinfiltered )
RETURN
Result

How can I split weekly data to monthly using Excel/ Power Pivot?

My Data is in weekly buckets. I want to split the number into a monthly number but, since there is an overlap in days falling in both the months, I want a weighted average of the data in terms of days that fall in each of the months. For example:
Now, in the above picture, I want to split that 200 (5/7*200 in Jan, 2/7 in Feb). How can I do that using Excel/ Power Pivot/ Dax Functions? Any help here is much appreciated.
Thank you!
Assuming your fact table looks something like below. Values are associated with the starting date of the week it occurred.
Although it may actually be a more granular data, having multiple rows for each week with additional attributes (such as identifiers of a person, a store, depending on the business), what being shown below will work the same.
What we need to do first is to create a date table. We can do that in "Design" tab, by clicking "Date Table", then "New".
In this date table, we need to add a column for starting date of the week which the date of each row is in. Set the cursor to "Add Column" area, and input following formula. Then rename this column to "Week Start Date".
= [Date] - [Day Of Week Number] + 1
Now, we can define the measure to calculate the number allocated to each month with following formula. What this measure is doing is:
Iterating over each row of the fact table
Count the number of days for the week visible in the filter context
Add the value portion for the visible days
Value Allocation := SUMX (
MyData,
VAR WeekStartDate = MyData[Week]
VAR NumDaysInSelection = COUNTROWS (
FILTER (
'Calendar',
'Calendar'[Week Start Date] = WeekStartDate
)
)
VAR AllocationRate = DIVIDE ( NumDaysInSelection, 7 )
RETURN AllocationRate * MyData[Value]
)
Result in the pivot table will be looking like this.

Power Pivot "dynamic" joins

I have a situation where I kind of need a many-to-many join - which I know isn't possible.
I have one fact table and two dimension tables.
The fact table contains account numbers (as in GL accounts) and amounts. Plus a date field, so the account numbers are not unique.
The first dimension table has just one column listing the reports that can be created by combining the accounts in different ways.
The second dimension table could be called a "roll-up" table. It has 3 columns: report, account, and a line item description field. The latter defines which line on the respective report that the account should be mapped to.
So I want to have a pivot table that has the line item description in the row area and the amount in the values area. With a mechanism for the user to specify which report they want to view. But the join on the account field between the roll-up table and the fact table is many-to-many. If the roll-up table were somehow filtered based on the specific report that the user has selected, THEN it would become one-to-many. Hence the "dynamic" joins in my title.
I've been trying to come up with a connecting table of some kind, but without any luck so far. If anybody has any suggestions/pointers, that would be much appreciated.
I figured out a way to do it using a DAX formula that calculates the field to be placed in the Values area. It uses FILTER and CROSSJOIN combinations to effect the dynamic joins. Note that in order to use a CROSSJOIN I added prefix letters to a couple of the field names (to make them unique). Also, I made it that the Report table (the first dimension table I described) has only one row - containing the report that the user wishes to view.
The DAX formula is as follows:
SUMX (
FILTER (
CROSSJOIN (
fBalances,
FILTER (
CROSSJOIN (
dRollUp,
dReport
), dRollup[Report] = dReport[uReport]
)
), fBalances[fAccount] = dRollUp[Account]
), fBalances[Amount]
)
Subsequent update: I moved it into Power BI where I added a parameter (called myReport) for the user to specify the report. Consequently I deleted the dReport table.
So the Power BI DAX formula becomes:
SUMX (
FILTER (
CROSSJOIN (
fBalances,
FILTER (
CROSSJOIN (
dRollUp,
myReport
), dRollup[Report] = FIRSTNONBLANK ( myReport[myReport], TRUE() )
)
), fBalances[fAccount] = dRollUp[Account]
), fBalances[Amount]
)

Calculated measure MDX through Pivot Table Excel

I am connected to OLAP cube, I created a pivottable.
I would like to know if with the OLAP tool of excel is possible to calculate the number of distinct invoice number taking acount the current filters like year, country and region of the pivot table ?
I tried with Countdistinct it gives me the same result for each country.
DistinctCount([PO TYPE].[PO NUMBER].[PO NUMBER])
Try using COUNT instead:
Count(
Exists(
[PO TYPE].[PO NUMBER].[PO NUMBER].MEMBERS,
[Geography].[Country].CURRENTMEMBER,
"MeasureGroupName"
)
)
You need to replace "MeasureGroupName" with a measure group name in your cube

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

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:
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:
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:
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])

Resources