While working on a sales report for an entertainment company ( bars and nightclubs), I normally just sum sales and I get the daily sum of sales. but I was communicated that their business day starts at 6 am of each and closes at 5:59:59 am the next day. basically sales reported Monday are the sales from 6 am Sunday thru 5:59:59 am Monday.
the company operates throughout the US so we have multiple time zones as well
the table has the following columns:
Transaction id, location, Transaction_datetimeLocal, TransactionDateTimeUTC, Transaction amount
how do I define / filter the calculation to be from 6am one day to 5:59:59 am the next day USING Power BI / DAX
TIA
In Power BI you have your table with the local time. You need to add a calculated column with the following DAX formula:
Business Time = 'Table'[Local Time] - TIME(6, 0, 0)
From this new column you could the create your business date with
Business Date = 'Table'[Business Time].[Date]
This is how it looks in the Data view:
Related
Is there a way to set the Start Date parameter to 1, next day would be 2, next day would be 3.
I would like to group on this and do day/week/month/year summaries.
I want to change the report that is attached to be a matrix report displaying days instead of dates starting with day 1 for whatever day is chosen. To go across the columns in a matrix and then aggregate those calculations to week/month/year summaries
Current Report by Date
I used the DAY function in SSRS. DAY(Fields!created_date.Value)
This is my first question on stackoverflow, sorry if the question is poorly put.
I am currently developing a project where I predict how much a person drinks each day. I currently have data that looks like this:
The menge column represents how much water a person has actually drunk in 30 minutes (So first value represents amount from 8:00 till before 8:30 etc..). This is a 1 day sample from 3 months of data. The day starts at 8 AM and ends at 8 PM.
I am trying to forecast the Time Series for each day. For example, given the first one or two time steps, we would predict the whole day and then we know how much in total the person has drunk until 8 PM.
I am trying to model this data as a Time Series object in R (Google Colab), in order to use Croston's Method for the forecasting. Using the ts() function, what should I set the frequency to knowing that:
The data is half-hourly
The data is from 8:00 till 20:00 each day (Does not span the whole day)
Would I need to make the data span the whole day by adding 0 values? Are there maybe better approaches for this? Thank you in advance.
When using the ts() function, the frequency is used to define the number of (usually regularly spaced) observations within a given time period. For your example, your observations are every 30 minutes between 8AM and 8PM, and your time period is 1 day. The time period of 1 day assumes that the patterns over each day is of most interest here, you could also use 1 week here.
So within each day of your data (8AM-8PM) you have 24 observations (24 half hours). So a suitable frequency for this data would be 24.
You can also pad the data with 0 values, however this isn't necessary and would complicate the model. If you padded the data so that it has observations for all half-hours of the day, the frequency would then be 48.
GIVENS:
Tools: SQL Server, SSMS 2016, R
Data: Hourly samples starting 2017-12-31 23:00:00 thru 2021-02-05 08:00:00
WANT: To chunk data into 7-day blocks ideally coinciding with week of year and grab averages for each 7-day period. Willing to sacrifice some data frontend and/or backend. Would like to reduce data frequency from 12x365 points down to perhaps 52 points per year. For end use in R.
PROBLEM(S):
A) SQL datepart(week,...) method does not consider 1st seven days of 2018 as week 1. Considers that week starts on a certain day of week, not necessarily on Jan. 1.
B) I suspect SQL datepart(week,...) will assign repeating week value across several years of data. So if I group by datepart(week...), won't it combine week 1 of 2018, 2019, 2020, 2021?
Here's my starting query (AvgDate is for debug purposes):
SELECT datepart(week,Date) Week,
FORMAT(AVG(HeadElev), '###.###') as AvgHeadEl,
COUNT(HeadElev) as Count,
FORMAT(AVG(datepart(Day, Date)), '##.###') as AvgDate
FROM [dbo].[Chickamauga] as CWL
WHERE '20171231' < Date AND Date <= '20181231'
GROUP BY datepart(week,Date)
ORDER BY Week
GO
Here's what my table looks like (I've split date & time from original data):
CREATE TABLE [dbo].[SomeLake](
[Date] [date] NULL,
[HourCT] [time](0) NULL,
[HeadElev] [float] NULL,
[TailElev] [float] NULL,
[Flow] [float] NULL
) ON [PRIMARY]
Again, trying to create simple 7-day blocks of samples and grab averages. (Not moving averages, I only want 1 data point per 7-day block.) I'm trying to reduce the data frequency from (hourly down to weekly data.)
End goal is to import into R and used time series functions that cannot accept high per year frequencies like 365. Trying to bring the frequency down to 52, ie. weekly data.)
THANK YOU for your kind assistance!
create simple 7-day blocks of samples and grab averages.
Group by something like:
1+datepart(dy,some_date)/7 week
which takes the day-of-year and performs integer division to group them into 7-day buckets, starting with 0.
I have the following problem,
I want to see the percentage of new sessions in a given month. I am specifically interested in new sessions by "direct" channelgrouping
in custom report I set dimensions for November: yearMonth, source, medium, channelgrouping. and metrics:percentNewSessions
it gives me 35%
then I create a custom reports with the same dimension but with Date as a metric.I average the %new session and get 38%
why does it differ? What should I trust?
Both of these measures are true, but they tell something different.
Another simple use case with date metric:
Day 1: visitor A
Day 1: visitor B
...
Day 7: visitor A
Day 7: visitor C
— Week unique visitors: 3
— Week sum of daily unique visitors: 4
Define your KPI, what is measured, how it is measured, the period for measurement, and always stick with the KPI parameters; else you're on another one :)
I need to prepare a yearly management report to show the total overtime (OT) work hours and minutes of all staff within time range and month.
The time format in ms sql 2000 database is as follows:
Each record will contains the FROM date & time and TO date & time
The report layout is as follows:
I had no idea how to divide and calculate the total hours & minutes within the time range as each OT records will overlap several time range and date.
Please help. Thanks.
Joe
The SQL DateDiff function can be used to compute the number of minutes, i.e.
declare #fromDT datetime
declare #toDT datetime
set #fromDT = '10/22/2011 18:30'
set #toDT = '10/22/2011 22:45'
select #fromDT,#toDT,DATEDIFF(mi,#fromDt,#toDt),
ltrim(str(DATEDIFF(mi,#fromDt,#toDt)/60))+':'+
ltrim(str(DATEDIFF(mi,#fromDt,#toDt)%60)) as HoursMin
Returns
StartTime End Time Mins HoursMin
2011-10-22 18:30:00.000 2011-10-22 22:45:00.000 255 4:15