Forum Discussion
Anonymous
6 years agoNot applicable
Query Assistance Please!
I am using the below query to import the previous 7 days worth of data. I would like to change the query to pull a date range. Is this possible? I have tried every way I know, nothing works. I highli...
- 6 years ago
Hi @dpattengale ,
There is 2 way you can get the data range into power bi:step 01:Creata a calendar table and set the date range on your way
step 02: in the source query editor you could change your code like this:SELECT TOP (100) PERCENT Rtrim(r.NAME) AS rName, pr.type, pr.sequence, d.parkrideid, pr.ridename, Datediff(minute, d.timedown, d.timeup) AS DownTimeMins, d.timedown, d.timeup, s.NAME, Rtrim(d.reason) AS Reason, Rtrim(d.resolution) AS Resolution, Rtrim(d.comments) AS Comments, pr.parkid, p.NAME AS Expr1# FROM dbo.parkridedowntimes AS d INNER JOIN dbo.parkrides AS pr ON pr.id = d.parkrideid INNER JOIN dbo.parks AS p ON pr.parkid = p.id INNER JOIN dbo.downtimesubtypes AS s ON d.downtimesubtypeid = s.id INNER JOIN dbo.rides AS r ON pr.rideid = r.id WHERE d.timedown >= Dateadd(day, -7, Getdate())To look at a specific date range change the Where-statement to e.g.
WHERE d.timedown between '2019-01-01' and '2019-09-30'
Cheers,
Pratima
Shuwyyyy
6 years agoAdvocate I
Hi @dpattengale ,
There is 2 way you can get the data range into power bi:
step 01:Creata a calendar table and set the date range on your way
step 02: in the source query editor you could change your code like this:
SELECT TOP (100) PERCENT Rtrim(r.NAME) AS rName,
pr.type,
pr.sequence,
d.parkrideid,
pr.ridename,
Datediff(minute, d.timedown, d.timeup) AS DownTimeMins,
d.timedown,
d.timeup,
s.NAME,
Rtrim(d.reason) AS Reason,
Rtrim(d.resolution) AS Resolution,
Rtrim(d.comments) AS Comments,
pr.parkid,
p.NAME AS Expr1#
FROM dbo.parkridedowntimes AS d
INNER JOIN dbo.parkrides AS pr
ON pr.id = d.parkrideid
INNER JOIN dbo.parks AS p
ON pr.parkid = p.id
INNER JOIN dbo.downtimesubtypes AS s
ON d.downtimesubtypeid = s.id
INNER JOIN dbo.rides AS r
ON pr.rideid = r.id
WHERE d.timedown >= Dateadd(day, -7, Getdate())To look at a specific date range change the Where-statement to e.g.
WHERE d.timedown between '2019-01-01' and '2019-09-30'
Cheers,
Pratima
- Anonymous6 years agoNot applicable
Thank you for your help Shuwyyy, this works perfectly!