Forum Discussion
Query Assistance Please!
- 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
Hi Anonymous ,
where did you get that string from? And what have you tried? Have you recived any error messages? And what range do you want to look at?
You could change your code like this:
1. In power query, for your table, double click on the Source-step.
2. Expand the Advanced options
3. You will see your current query in the SQL Statement box.
Your code in the SQL Statement-window should look something 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 >= Dateadd(day, -14, Getdate()) && d.timedown <= Dateadd(day, -7, Getdate())
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.