i have this error on the power query.
Formula.Firewall: Query 'Gunduz' (step 'Source') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.
i have the query which is working fine on SQL side but Power Query has a problem with it. First Table7 is a "connection only" as a separate query.
Output text of the query is also fine
The Query is as follows :
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
On the other hand, another server, another database similar code is working just fine...
let
param = TarihAraligi,
ilktarih = param {0} [Custom],
sontarih = param {1} [Custom],
dbQuery = "SELECT #(lf)H.ACCOUNTCODE collate SQL_Latin1_General_CP1254_CI_AS AS 'HESAP NO', #(lf)E.DEFINITION_ collate SQL_Latin1_General_CP1254_CI_AS AS 'HESAP ADI', #(lf)E.EXTNAME collate SQL_Latin1_General_CP1254_CI_AS AS 'HESAP ADI-2', #(lf)E.SPECODE collate SQL_Latin1_General_CP1254_CI_AS AS 'HESAP OZELKODU', #(lf)SUM(H.DEBIT) 'BORC', #(lf)SUM(H.CREDIT) #(lf)'ALACAK', SUM(H.DEBIT-H.CREDIT) 'BAKIYE', #(lf)SUM((1-H.SIGN)*H.REPORTNET) 'DOVIZ BORC',#(lf)SUM(H.SIGN*H.REPORTNET) 'DOVIZ ALACAK', #(lf)SUM((1-H.SIGN)*H.REPORTNET-H.SIGN*H.REPORTNET) 'DOVIZ BAKIYE', #(lf)SUM(H.EMUDEBIT) 'EURO BORC', SUM(H.EMUCREDIT) 'EURO ALACAK', #(lf)SUM(H.EMUDEBIT-H.EMUCREDIT) 'EURO BAKIYE', #(lf)E.UNITS collate SQL_Latin1_General_CP1254_CI_AS AS 'BIRIM' #(lf)FROM LG_076_01_EMFLINE H #(lf)LEFT JOIN LG_076_EMUHACC E ON E.LOGICALREF=H.ACCOUNTREF #(lf)WHERE (H.TRCODE IN (1,2,3,4,6,7)) AND (H.CANCELLED = 0) AND (H.STATUS = 0) AND H.DATE_>='" & ilktarih & "' AND H.DATE_<='" & sontarih & "' #(lf)GROUP BY H.ACCOUNTCODE, E.DEFINITION_, E.EXTNAME, E.SPECODE, E.UNITS #(lf)",
Source = Sql.Database("teqsql", "logo", [Query=dbQuery])
in
Source
Always ignore privacy
in the settings... – Umut Kignore privacy
solved my problem. but developers shall solve this problem so we dont have to put ourselves into risk. – Umut K