命名查询在 ssas 多维数据集中显示错误的票证状态名称

发布于 2024-11-26 10:49:49 字数 1737 浏览 5 评论 0原文

我在该查询中编写了命名查询,我具有 request_id、createddate、confirmeddate、reporteddate、sitename、ticketstatusname 等属性......

我想知道 request_id 的 Ticketstatusname,即打开或关闭。我已将特定日期的日期过滤为 ReportedDate='2011-07-31 00:00:00.000' 我想知道每个站点有多少个 request_id 处于打开状态以及有多少个处于关闭状态。例如 sitename='BOUZ' 包含25 个 request_id 处于打开状态,225 个 request_id 处于关闭状态。我在 ssas 多维数据集中复制并粘贴了相同的查询,当我将站点名称、ticketstatusname 拖放到多维数据集浏览器中时,我进行了处理,计数正确,但 Ticketstatusname 我出错了,即实际关闭的票证显示为打开状态。请您帮忙解释一下为什么我的 ssas 多维数据集中的 request)id 的状态错误。以下是命名查询。

SELECT *
FROM
  (SELECT d.Short_sitename AS Sitename,
          f.Request_ID,
          dt3.FullDateAlternateKey AS CreatedDate,
          dt2.FullDateAlternateKey AS ConfirmedDate,
          dt1.FullDateAlternateKey AS ReportedDate,
          CASE
              WHEN (dt2.FullDateAlternateKey IS NULL)
                   OR (dt1.FullDateAlternateKey<dt2.FullDateAlternateKey) THEN 'Open'
              ELSE 'Closed'
          END AS TicketStatusName,
   FROM FactTicket AS f
   LEFT OUTER JOIN DimTime AS dt3 ON dt3.TimeKey = f.Create_DateKey
   LEFT OUTER JOIN DimTime AS dt2 ON dt2.TimeKey = f.Confirmed_DateKey
   LEFT OUTER JOIN DimSite AS d ON d.Site_ID=f.Site_ID
   LEFT OUTER JOIN DimTime AS dt1 ON dt1.FullDateAlternateKey BETWEEN dt3.FullDateAlternateKey AND DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, ISNULL(dt2.FullDateAlternateKey, GETDATE())) + (12 - MONTH(ISNULL(dt2.FullDateAlternateKey, GETDATE())) + 1), 0))
   WHERE (dt1.FullDateAlternateKey = DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, dt1.FullDateAlternateKey) + 1, 0)))
     AND (f.Type_ID1 IS NOT NULL)
     AND (f.Type_ID2 IS NOT NULL)
     AND (f.Type_ID3 IS NOT NULL) )A
WHERE ReportedDate='2011-07-31 00:00:00.000'
  AND sitename='BOUZ'

i have written named query in that query i have attributes like request_id,createddate,confirmeddate, reporteddate,sitename,ticketstatusname etc.....

i want to know ticketstatusname for request_id's i.e open or closed. i have filtered date as ReportedDate='2011-07-31 00:00:00.000' for particular date i want to know how many request_id's are in open and how many are closed for each site.for example sitename='BOUZ' that containing 25 request_id's are open and 225 request_id's are closed. same query i have copied and past in ssas cube and i processed when i drag and drop sitename,ticketstatusname into cube browser i am getting count correctly but ticketstatusname i am getting wrong i.e actually closed tickets are showing in open status. plese can you help why i am getting wrong status for request)id's in my ssas cube. Following is the named query.

SELECT *
FROM
  (SELECT d.Short_sitename AS Sitename,
          f.Request_ID,
          dt3.FullDateAlternateKey AS CreatedDate,
          dt2.FullDateAlternateKey AS ConfirmedDate,
          dt1.FullDateAlternateKey AS ReportedDate,
          CASE
              WHEN (dt2.FullDateAlternateKey IS NULL)
                   OR (dt1.FullDateAlternateKey<dt2.FullDateAlternateKey) THEN 'Open'
              ELSE 'Closed'
          END AS TicketStatusName,
   FROM FactTicket AS f
   LEFT OUTER JOIN DimTime AS dt3 ON dt3.TimeKey = f.Create_DateKey
   LEFT OUTER JOIN DimTime AS dt2 ON dt2.TimeKey = f.Confirmed_DateKey
   LEFT OUTER JOIN DimSite AS d ON d.Site_ID=f.Site_ID
   LEFT OUTER JOIN DimTime AS dt1 ON dt1.FullDateAlternateKey BETWEEN dt3.FullDateAlternateKey AND DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, ISNULL(dt2.FullDateAlternateKey, GETDATE())) + (12 - MONTH(ISNULL(dt2.FullDateAlternateKey, GETDATE())) + 1), 0))
   WHERE (dt1.FullDateAlternateKey = DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, dt1.FullDateAlternateKey) + 1, 0)))
     AND (f.Type_ID1 IS NOT NULL)
     AND (f.Type_ID2 IS NOT NULL)
     AND (f.Type_ID3 IS NOT NULL) )A
WHERE ReportedDate='2011-07-31 00:00:00.000'
  AND sitename='BOUZ'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文