Powerpivot data that spans over multiple filter values - excel

I have outage information stored in Excel Powerpivot. I am trying to use Powerpivot to display and calculate uptime availability per month, however, I am a bit stuck with outages that spans over two months.
My current setup:
Outage table has four columns: Application, Outage Start Time, Outage End Time, Duration. Duration is a calculated column that is the difference between the end time and start time.
The Outage Start Time is connected to a date table. I have slicers per month, so users can select the month they like to see availablity data, and powerpivot table will show availability for that month for different applications.
If the outage start time and end time falls within the same month, then availablity calculation is correct. However, for example, if the outage starts at the end of July and ends at the beginning of August, then this is only considered to be an outage for July (because of how the start time is tied to the date table). Ideally, I would like to see the duration of this outage split up over both July and August. Is this possible?
Thanks!

Tallie,
It's absolutely possible! I solved it by creating 2 calculated columns on the Outage Table:
One to determine the duration of the outage in the current month:
=if([End]>EOMONTH([Start],0),EOMONTH([Start],0)-[Start],[End]-[Start])
And another to determine the outage in the following month:
=if([End]>EOMONTH([Start],0),[end]-EOMONTH([Start],0),blank())
It then becomes the slightly more complex where I want to create a measure that not only sums the current month outage but also the following month outage from the previous month. I began by creating a measure that sums each of the 2 calculated columns respectively - this is good practice as it helps a logical build up and improves performance:
[Cur Month Dur] = sum(Outage[Cur Month Outage])
[Following Month Dur] = sum(Outage[Following Month Outage])
I then add to the [Cur Month Dur] a filtered version of the [Following Month Dur] which opens the filter context of the measure and looks in the date table for the previous month (must be numeric):
=[Cur Month Dur] +
CALCULATE([Following Month Dur],
FILTER(
ALL(dimDate),
dimDate[Month Number]=max(dimDate[Month Number])-1
)
)
You can find a detailed explanation of the method here.
I uploaded my workings to SkyDrive which you might find useful.
HTH
Jacob

Related

Number of times an event occurs per year depending on start date and frequency (excel)

I'm trying to develop a formula in MS Excel that will give me the number of occurrences a task will happen in a year (or month), based on a start date, frequency and schedule in a table. I am looking to produce a table like the following (assuming the start date is 01/01/YR1):
I'm open to VBA suggestions also.
The minimum frequency is completing the task every week. Not taking into account daily tasks here. The data is held in a table. I calculated the 'times per year' using :
=IF([#Schedule]="Months",(12/[#Frequency]), IF([#Schedule]="Weeks",(52/[#Frequency]),IF([#Schedule]="Years",1/[#Frequency],0)))
I may look to take this onto a monthly schedule also, i.e. number of occurrences for each month across 5 years. It would also be useful to specify an overall end date for when the tasks would stop. (e.g. sometimes it would be year 3, sometimes year 5)
Your help is much appreciated!
=IF(D$2=1,ROUND(D$2*$C3-0.45,0),ROUND(D$2*$C3-0.45,0)-SUM($D3:OFFSET($C3,0,D$2-1)))
The formula is dragable so just place it in D3 then drag across then down. Also note the change in format of the table so the year numbers are usable in the calculations.
Note: I would suggest that the value the 5th year of the 2.5 year frequency is incorrect.
In the 3rd year you would do it and have a half year remaining. Then add that to years 4 & 5 and you get 2.5 time to do it again.

Calculation of the absence rate per employee

The goal is to use Dax and Power Pivot to determine what the absentee rate per employee is. This lowest granularity can be used later to determine the average absence per area.
I get from the team leaders an overview (Excel), which is shown per day, whether the employee was there on the day or sick or on vacation
tblOverview
Date - Name - State - Area - Shift
Date: Date from 01.01.- 31.12.
Name: Name of the person
State: A = present, E = absent
Area: area
Shift: Week shift or weekend shift (Mo + tue day off)
Since the employees have different shift models, this is probably a somewhat more difficult task. Most work from Monday to Friday. However, some work from Wednesday to Sunday.
Somehow I have to find out how many working days each employee has per week / month and how many days he has been absent. Only how best?
Can this be elegantly solved using a Dax function without adjusting the structure of the table?
I am happy about every contribution!
Edit:
The first pivot table shows how many days every employe have worked ("A") per week.
The second pivot table shows the absence days ("E"):
enter image description here
The result should be shown in the same structure.
First, the function should compare if the day for each employee is a working day in comparison to the shift model (either mo-fri or wed-sun) and then if the employee is off ("E"). If the employee is off, the availability should be 0% or the absence 100% for the respective day.
Here you have an example table/ file:
enter link description here

Cognos Report totaling hours over time

I'm pretty new to Cognos 10 Report Studio so this may be a fairly simple question but I have been unable to find on answer so far.
In my database I have the hours a person has worked in a two week pay period, as well as what month a pay period exists in. I would like to total the over any period of months.
For example a user is prompted to choose a range of time, and they may select a start month of January of some year, and an end date of June of the same or some later year, and then the report would have a column that displays the sum of hours worked by a person between that time frame.
So in essence the sum of hours for every pay period in a given range of dates.
Thank you very much for your help.
If you want a list (or crosstab) with the User, year, month, and total hours in each month
Create a new data item (maybe something called - Hours by Month) defined as:
total([hours] for [Year], [Month], [User])
The function allows you to define the scope so the SQL is structured to give you the answer grouped the way you want

Calculate annual leave between two dates in Excel

This task seems easy enough yet I just can't figure a way of doing this without resorting to vba.
All I need is to know the number of hours an employee has used up on annual leave, based on a start and end date, and their hours of work.
To be more clear, this example shows one employees contracted hours from Monday to Sunday i.e. they work only Weds, Thurs, and Friday, for 7.5 hours each day.
Below shows the start and end date that the employee has chosen to take for annual leave. I need to calculate, based on their contracted hours, how much annual leave is used between the two dates. The answer would be 45 hours in this case.
Here's another approach - I've expanded the days between the start and end dates into an array then used the resulting day numbers to offset into the days of work range
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1)))
If you had a list of holiday dates somewhere (say in I3:N3) you could exclude them as follows
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1))*ISNA(MATCH(ROW(INDIRECT(A6&":"&B6)),I3:N3,0)))
- it is a bit long-winded but the only way I can think of at the moment.

How to compare columns for related records in the same Power PIvot table (DAX)

I have a fact table consisting of schedule data tracked over many months. An activity will have an entry for each month. I want to see if an activity started and finished on time by comparing each activity's start and finish dates to the previous month's forecasted start and finish dates.
Here is an example of what I want. The Started/Finished On Time columns are the calculated columns I want to make.
Example 1: Activity 1 did not start or finish on time in November, but did start on time in December. It did not finish on time so the Finished on Time column is marked "late".
Example 2: Activity 3 started earlier than was forecasted (12/7 start vs. 1/5 start). So it should be marked as starting early.
So pretty much the following needs to happen in the Started on Time column (similarly in Finished on Time column):
For each row, find the same activity from last month and compare the start dates (I think I can figure the rest out but this is the real challenge at the moment)
If the current row's start date is in the same month as the snapshot date and is in the same month as the
forecasted start from the other record OR if there is no previous month's record, then return "On Time".
Otherwise, if the current row's start is in the same month as the snapshot date but earlier than the start date from the previous month, return "Early"
Otherwise, if the current row's start is in the future and the previous month's start date was in the future, return "Not Started"
Otherwise, return "Late"
Is this even doable? I feel like this would require some careful use of LOOKUPVALUE and EARLIER, but I'm not sure how to go about it.
Looks like this describes how to do it in Power Pivot completely: Can I compare values in the same column in adjacent rows in PowerPivot?
Performance problems can be solved by moving this partly or completely to Power Query: http://www.powerpivotpro.com/2015/03/how-to-compare-the-current-row-to-the-previous-row-in-power-pivot/

Resources