Datediff between a sliced date and a table date - powerbi-desktop

I am making a PowerBI report using a datetable and a table where I have startdates. I use the datetable in a slicer as a reference date. Now I want to calculate the number of days between the reference date and the startdates.
Can you help me?

Related

Retrieving specific data from column in pivot table

The data in my pivot table is sorted according to the date (oldest to newest). The column with dates is only comprised of business days. I have formulas to retrieve data from the latest and earliest dates using MAX and MIN functions. Let's say the latest date is 2017-06-30 and the earliest date is 2016-10-01. Then the following functions retrieve the desired data from those dates. (Column A is the date column).
=GETPIVOTDATA("A";$A$4;"B";"C";"TO_DATE";MAX(A:A);"D";"E") =GETPIVOTDATA("A";$A$4;"B";"C";"TO_DATE";MIN(A:A);"D";"E")
Note that I have hidden some of the column names. What I would like to do now is to get data from 5 business days/30 business days/90 business days before the date specified by
=GETPIVOTDATA("A";$A$4;"B";"C";"TO_DATE";MAX(A:A);"D";"E").
Is there a way to accomplish this without using the WORKDAY function where I have to specifiy the holidays? This was my initial thought, but I don't want to specify the holidays, so the following function won't work
=GETPIVOTDATA("A";$A$4;"B";"C";"TO_DATE";WORKDAY(MAX(A:A);-5);"D";"E")
I tried to use the OFFSET function, however it seems that I can't use the cell value as a cell reference.

Format date and Value

I have a synchronized List from SharePoint in Excel with Date, Names and sold items to sume.
The Date appears as Datetime(2017-01-01 13:00:00).
In order to do a Pivot Table I wanted to Format it so only appears the month and the year. (January 17).
The Problem is, although the Date is in Month-Year Format, when I do the Pivot table it seems to get the original values of the date, so it doesn´t recognize "January 17" as a Month and it repeats the field several times because it still recognize it as a DateTime value and I can´t get the sold items of one month.
Please have a column to convert the format 2017-01-01 13:00:00 to January-17
If the datetime is in cell A1 use the formula below,
=TEXT(A1,"mmmm-yy")

Powerpivot incorrectly convert date value to text in pivot-table

I'm using Powerpivot to create a pivot table in Excel.
In Powerpivot,the Date_Received column is correctly formatted as Date (dd/mm/yyyy) and all of the date columns are working correctly in Powerpivot. However when I try to summary data by pivot table in excel, all the date columns are converted to text and behave as text in pivottable.
Consequently, I can't not group the result by Year, Month... or even sort data from Oldest to Newest.
I think it is a very common problem with Powerpivot, could someone please help?
My guess is that you are UK based? It's a well known and long standing issue that is connected to PowerPivot failing to properly understand the date format.
There are some things you need to do to get round this:
Use a separate date table that has a column of unique, continous dates that cover your required period. Each other table with dates should be linked to this.
In the PowerPivot window on the 'Design' tab mark this as your date table with your date column as 'the date'
Change the format of this date column in the PowerPivot window to something that is non ambiguous - I tend to use yyyy-mm-dd.
At this point any pivot you create using this column will be sortable by date and the date filters will become available.

Using Date with GetPivotData

I have a pivot table that I am trying to reference using a date as part of the lookup. The pivot table data can be grouped by day, week or month (there is a little VBA that controls this) However, I cannot seem to create a GETPIVOTDATA function that will work with all three groupings.
- When grouped by day, GETPIVOTDATA seems to want the day of the year (1-365), it won't accept a date.
=GETTPIVOTDATA(value, pt, "Date", 184)
When grouped by week, it will accept a date and return the week that the date falls in
=GETTPIVOTDATA(value, pt, "Date", Date(2012, 08, 22))
When grouped by month, it seems to want the month of the year (1-12)
=GETTPIVOTDATA(value, pt, "Date", 11)
Is there anyway to use a date with all three groupings? Bear in mind that the groupings will change but the formula won't so the same formula has to work with any grouping.
The alternatives are using an IF statement and date manipulation or using VBA whenever I change the groupings. However, I feel that the should be a way to just use the date, regardless of the grouping.

Excel to specify the month to report the data

Using excel, is it possible to specify the month to report in a cell?
For example, excel would need to report the latest reported sales, if its available. If the month of February sales is not available, then it will report January sales. Likewise, if March sales is available, it would report the sales in March.
How do you write this formulae in a cell in excel? If its not possible to write such a formuale, can we write a vba to do this?
If you mean you have a list of sales entries and want the sales for the last month in the data, you could write one formula to get the latest month. If months are in A you could write: =month(max(A1:A99999))
Note if you have multiple years data, you need to pull the year too or get bounding dates. You can then sum sales using an array formula like assuming the result of the first action is in D1 and sales are in B: {=sum(if(month(A1:A999999)=D1,B1:B999999,0))}
If you have incremental updates during the month, this will return month to date data. If you need data for the last full month, you can use another array formula to get the maximum month where the date is the last day of the month.
If the cells for future data in B1:B12 are blank then you just need to extract the last number in B1:B12 don't you? If so then try
=LOOKUP(9.99E+307,B1:B12)
You can use the OFFSET function to select specific data based on the month.
Insert a formula to calculate the current month (or just type in the month number)
=MONTH(TODAY())
The formula to select the current months of sales data
=SUM(OFFSET(B1,MONTH(TODAY()),0,1,1))
Have a look at the help in Excel on the OFFSET function. It can be used to select a range of data. For example, to return data from the start of the year to the current month the formula would be:
=SUM(OFFSET(B1,1,0,MONTH(TODAY()),1))
If the current month does not contain data yet, you can test to see if a value is returned and revert to the prior month if there is no data.
=IF(SUM(OFFSET(B1,B16,0,1,1))=0,SUM(OFFSET(B1,B16-1,0,1,1),SUM(OFFSET(B1,B16,0,1,1))))
I found this answer:
=IF(B12<>0,B12,IF(B11<>0,B11,IF(B10<>0,B10,IF(B9<>0,B9,IF(B8<>0,B8,IF(B7<>0,B7,IF(B6<>0,B6,IF(B5<>0,B5,IF(B4<>0,B4,IF(B3<>0,B3,IF(B2<>0,B2,IF(B1<>0,B1,0))))))))))))
This formulae solves the problem of picking up the latest available data.

Resources