Calculate lead-time in PowerBi - powerbi-desktop

I am working on a report in PowerBi. I have several statuses and their dates in one cells and I need to separate them into columns
My target is to be able to calculate a lead-time between the statuses and their dates in PowerBi.
When I tried the donction examples, it only took the fist date on the first status...

Related

IF statement for multiple date ranges

I built a tracker for my platoon to manage numerous training dates based on completion. Each sheet tracks different things and I'm trying to make a coversheet that pulls data from each sheet to give an overall snap shot. I'm trying to create and IF formula for if any of the dates in a certain row are over due, it reports as over do. I can do it with 1 or 2 but not with 14 different dates. Is this possible?

Calculating Weekly Average in Excel 2019 using (DAX, Powerpivot, Powerquery)

I have data in my table
I want to calculate weekly average. Like this
I can acomplish this by excel formulas but I am not fan of formulas. I need DAX, powerquery or powerpivot solution to automate the task.
The attached workbook uses power query to get to your desired output.
Steps
Replicate the date column
Transform the replicated date column to start of week
Group Rows by StartofWeek; create three additional columns
Close & Load as query conneciton only
Create a second Table query by repeating steps 1,2
Merge queries, joining on StartOfWeek column
Expand the WeeklyAvg columns and show the averages that you desire
This could also be done differently via DAX. Please let me know if this answers your request or if you have additional comments/suggestions. Thanks!
https://1drv.ms/x/s!AmcGUE_vrclQ7yIG6ZGnErO4m2LT?e=flnqio

Lookup previous date for the same item in an unsorted table

Trying to create a way to QC daily data before pulling it into Spotfire to automate a monthly report. The data is sourced from the field so the data quality isn't the greatest. Plus some days get missed because there wasn't a guy working in the area that day.
I tried doing all of the calculations in Spotfire and managed to get it but after talking to some folks when I was asking about ways to QC the data. They all suggested doing the calculations, data cleaning, and QCing in Excel before pulling it into Spotfire.
Not sure how to put a table in here but are the important columns.
Column A: unique well identifier
Column G: hours and value that I want to lookup
Column I: date
I managed to get all of the calculations and filtering completed within Spotfire but am wanting to replicate them in Excel.
The first thing I am trying to do is pull the previous dates HOURS value (Column H). Some wells will have a value on the previous date and some might not.
The below formulas are a few that I tried out:
Formula 1: =DATE(YEAR(DATA!$I2),MONTH(DATA!$I2),DAY(DATA!$I2)-1)
Formula 2: =INDEX(A:I,MATCH(1,(I:I=DATA!$I2)*(A:A=DATA!$A2),1),9)
Results:
Formula 1 always yielded the previous day which would work for 99% of
the cases.
Formula 2 yielded #N/A
I don't know why you don't want to do the whole thing using Spotfire.
Here is an example of an expression, using Spotfire, to get the previous date (which seems to be what you want, but without a dataset it is hard to figure out) :
Min([Date_Col]) OVER (Previous([Date_Col]))
You may want to use the DatePart function first to only have the date if you currently have a datetime

Excel - Take Average of Monthly Data

I have a historical data set for commodity pricing. Throughout the data set, the data starts inputting prices on specific days, rather than the average of the entire month. In order to keep the flow of having only the average pricing for the months.
In the best case scenario, I would use an Averageif function, however, the data for each month doesn't display a consistent amount of days.
How can I automate this the process: If the month is the same as the previous row and different than the next row, calculate the average of the ^ rows until you hit the next month.
Here's a simple display of what I mean:
]1
You can use a pivot table to get the output you want. It will also be neatly organized instead of having your averages mixed in with a mostly blank column. Photo below shows the set-up/output of a pivot table generated with random data.
For a solution without pivot tables, you can use the following formula :
=AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0))
The above example is from cell C1, and can be copied down the entire list. The dates are in $A$1:$A$30 and the values in $B$1:$B$30. The first conditions test on the first day of the month (calculated as A1-DAY(A1)+1),and the second condition as last day of the month (calculated as EOMONTH(A1;0)
This will obviously put the average value of the month on each row, but will also work if your data is not sorted on date. If this is the case, and you only want to display one number per month in the column (as in your own example), you can add an additional IF statement wrapped around the formula:
=IF(EOMONTH(A2;0)=EOMONTH(A1;0);"";AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0)))
So it will display empty in all cells, except where the month changes.

Month & Week grouping in excel pivot tables with some empty data

I am working to group data in excel and I am trying to sort the input dates by month and week. I've found a number of ways to group by weeks (including grouping the date by 7 days and adding a helper column in the pivot table that numbers the weeks), but I'm having a problem viewing months and weeks without data.
For example, in my data set during the month of October, 2 of the weeks have no input. When I try to make the pivot table "show rows with no data" it shows every week in the year, not only the weeks during the month of October.
I would like be able to show every week during the month of October, including those without data, without showing every week in the year. Has anyone encountered a similar issue? I'm on Excel 2016 but my colleague has the same issue on Excel 2013.
Thanks!
Here is a quick screenshot of the pivot table from the data. I am trying to make all of the weeks in the month of October show up regardless of whether or not there is data, but I don't want to see all of the weeks in the date range. I have sample data input from September 16th, 2018 to January 1st, 2019
Update for anyone looking to do this themselves:
I couldn't figure out a way to do this with Pivot Charts. They lack the ability to group by multiple days as well as by months and years. Instead, I used VBA to select the desired data from the pivot table by checking for the number of the month in each row. (mm/dd/yyyy - mm/dd/yyyy is the format pivot tables use to group days).
I added a dummy row which copied the date ("Date 2") and used that, grouped in 7 days, as the rows for the pivot table. Because I wanted to show items with 0 data I selected that option, which shows every group of 7 days from the first day entered until the last day entered. I used the original Date with Month and Year auto groups to insert Slicers to sort the data.
In VBA you can check which Slicers are selected and use that to determine the range of months you want to display on the inserted chart. This way you can look at one or two months at a time but still show weeks with no data.
While this solution is not particularly elegant, it did allow for a dynamic use of the data that can be adjusted to view specific months or years as was desired. Some useful resources for this method are included below. Again, it is an ugly way to get the desired result but if it works it works!
https://peltiertech.com/referencing-pivot-table-ranges-in-vba/
https://peltiertech.com/create-update-chart-using-partial-pivot-table/

Resources