电源查询 - 请重建此数据组合

时间:2017-02-14 13:24:32

标签: powerquery

我在电源查询中出现此错误。

  

Formula.Firewall:查询' Gunduz' (步骤'来源')引用其他   查询或步骤,因此它可能无法直接访问数据源。请   重建此数据组合。

我的查询在SQL端正常工作,但Power Query有问题。第一个表7只是一个"连接"作为单独的查询。

查询的输出文本也很好

Screenshot of the query text

查询如下:

class OutageSerializer(serializers.ModelSerializer):

    products = serializers.SerializerMethodField()

    def get_products(self, outage):
        products_qs = outage.products.filter(client=self.context['request'].client)
        return ProductSerialzier(products_qs, many=True).data

另一方面,另一台服务器,另一个类似代码的数据库正常工作......

let

    param1 = Table7,

    ilktarih = Text.From(param1 {0} [Value]),

    sontarih = Text.From(param1 {1} [Value]),

    dbQuery = " SELECT #(lf)#(tab)   pg.pgrpName1#(tab)#(tab)#(tab) [Santiye],#(lf)#(tab)   p.prsncode            [Sicil No],#(lf)       p.[prsnname1]         [Adi],#(lf)       p.[prsnname2]         [Soyadi],#(lf)       CLT.clntName1#(tab)#(tab) [Firmasi],#(lf)       fg3.grp3Name1#(tab)#(tab) [Gorevi],#(lf)       prf.pcntrName1#(tab)#(tab) [Ekibi],#(lf)       lnk11.lgrp11Name1#(tab) [Kaldigi Yer],#(lf)       lnk12.lgrp12Name1 +' - '+lnk12.lgrp12Name2 [Kamp/Adres],#(lf)       lnk13.lgrp13Name1#(tab) [Oda No],#(lf)       cast(t.ioTransactionDate as date) as Tarih,#(lf)       t.[iotransactiondate] [Giris Tarihi/Saati],#(lf)       (SELECT #(lf)#(tab)   #(lf)        t2.[iotransactiondate] #(lf)       #(lf)       #(lf)#(tab)#(tab)FROM   [Exen].[dbo].[IOTransaction] t2#(lf)       #(lf)#(tab)   #(lf)#(tab)#(tab)#(tab)  #(tab)  #(tab)  #(tab)#(lf)#(tab)#(tab)WHERE  ( t2.[iotransactiondate] = (SELECT Min(m.[ioTransactionDate])#(lf)                                  FROM   IOTransaction m#(lf)                                  WHERE  m.ioPrsnRefId = t2.ioPrsnRefId#(lf)                                         AND Cast(m.[iotransactiondate] AS DATE)#(lf)                                             = Cast#(lf)                                             (#(lf)                                             t2.[iotransactiondate] AS DATE)#(lf)                                  GROUP  BY m.ioPrsnRefId)#(lf)          OR t2.[iotransactiondate] = (SELECT Max(m.[iotransactiondate])#(lf)                                      FROM   IOTransaction m#(lf)                                      WHERE  m.ioPrsnRefId = t2.ioPrsnRefId#(lf)                                             AND Cast(m.[iotransactiondate] AS#(lf)                                                      DATE) =#(lf)                                                 Cast(#(lf)                                                 t2.[iotransactiondate] AS DATE)#(lf)                                      GROUP  BY m.ioPrsnRefId) )#(lf)       #(lf)       #(lf)       and ioStatus = 1#(lf)       and cast(t2.ioTransactionDate as date) = cast(t.ioTransactionDate as date) and t.ioPrsnRefId = t2.ioPrsnRefId#(lf)GROUP  BY #(lf)          t2.[iotransactiondate]#(lf)          #(lf)         )#(lf)       #(lf)       #(lf)       #(lf)       AS  [Cikis Tarihi/Saati],#(lf)       prsnEText4 [Vardiya],#(lf)       tz.tzoneName1 [GECE/GUNDUZ]#(lf)       #(lf)       #(lf)FROM   [Exen].[dbo].[IOTransaction] t#(lf)       LEFT JOIN dbo.person p#(lf)              ON t.ioPrsnRefId = p.prsnRefId#(lf)       LEFT JOIN dbo.PersonShift ps#(lf)#(tab)#(tab)#(tab)  ON ps.psPrsnRefId = p.prsnRefId#(lf)#(tab)   LEFT JOIN dbo.TimeZoneMess tz#(lf)#(tab)#(tab)#(tab)  ON tz.tzoneRefId = ps.psTzoneRefId#(lf)#(tab)   LEFT JOIN dbo.[PersonGroup] pg#(lf)#(tab)#(tab)#(tab)  ON pg.pgrpRefId = p.prsnPgrpRefId#(tab)#(lf)#(tab)   LEFT JOIN FreeGroup3 fg3#(lf)#(tab)#(tab)#(tab)  ON fg3.grp3RefId = p.prsnGrp3RefId#(lf)#(tab)   left join Client CLT#(lf)#(tab)#(tab)#(tab)  ON CLT.clntRefId = P.prsnClntRefId#(lf)#(tab)   LEFT JOIN [ProfitCenter] prf#(lf)#(tab)#(tab)#(tab)  ON prf.pcntrRefId = p.prsnPcntrRefId#(tab)#(lf)#(tab)   LEFT JOIN LinkedGroup11 lnk11#(lf)#(tab)#(tab)#(tab)  ON lnk11.lgrp11RefId = p.prsnLgrp11RefId#(tab)#(lf)#(tab)   LEFT JOIN LinkedGroup12 lnk12#(lf)#(tab)#(tab)#(tab)  ON lnk12.lgrp12RefId = p.prsnLgrp12RefId#(tab)#(lf)#(tab)   LEFT JOIN LinkedGroup13 lnk13#(lf)#(tab)#(tab)#(tab)  ON lnk13.lgrp13RefId = p.prsnLgrp13RefId#(lf)#(tab)   #(lf)#(tab)#(tab)#(tab)  #(tab)  #(tab)  #(tab)#(lf)WHERE  ( t.[iotransactiondate] = (SELECT Min(m.[ioTransactionDate])#(lf)                                  FROM   IOTransaction m#(lf)                                  WHERE  m.ioPrsnRefId = t.ioPrsnRefId#(lf)                                         AND Cast(m.[iotransactiondate] AS DATE)#(lf)                                             = Cast#(lf)                                             (#(lf)                                             t.[iotransactiondate] AS DATE)#(lf)                                  GROUP  BY m.ioPrsnRefId)#(lf)          OR t.[iotransactiondate] = (SELECT Max(m.[iotransactiondate])#(lf)                                      FROM   IOTransaction m#(lf)                                      WHERE  m.ioPrsnRefId = t.ioPrsnRefId#(lf)                                             AND Cast(m.[iotransactiondate] AS#(lf)                                                      DATE) =#(lf)                                                 Cast(#(lf)                                                 t.[iotransactiondate] AS DATE)#(lf)                                      GROUP  BY m.ioPrsnRefId) )#(lf)       AND p.[prsnname1] IS NOT NULL#(lf)       AND t.iotransactiondate >= '" & ilktarih & "'#(lf)       AND t.iotransactiondate <= '" & sontarih & "'#(lf)       AND ps.psStartDate <= t.[iotransactiondate]#(lf)       AND ps.psFinishDate > t.[iotransactiondate] #(lf)       AND tz.tzoneRefId =4#(lf)       and ioStatus = 0#(lf)GROUP  BY pg.pgrpName1#(tab),#(lf)#(tab)#(tab)  t.ioPrsnRefId,#(lf)          prsncode,#(lf)          prsnname1,#(lf)          prsnname2,#(lf)          t.[iotransactiondate],#(lf)          t.iostatus,#(lf)          tz.tzoneName1,#(lf)          ps.psStartDate,#(lf)          ps.psFinishDate,#(lf)          prsnEText4,#(lf)          fg3.grp3Name1,#(lf)          CLT.clntName1,#(lf)          prf.pcntrName1,#(lf)          lgrp11Name1,#(lf)          lgrp12Name1,#(lf)          lgrp12Name2,#(lf)          lgrp13Name1",

    Source = Sql.Database("Mayak", "Exen", [Query=dbQuery])
in
    Source

0 个答案:

没有答案