Forum Discussion

jay3828's avatar
jay3828
Frequent Visitor
3 years ago

dynamic m query with parameters getting an error "The import vendorList matches no exports."

I am trying incorporate paramers in my power bi reports.  I am using the snowflake connector and trying to add the select all to my query and running into issues.  Note. M code is not my specialty.  here is the code. looking for some help.  Thanks all.

my table where the list comes from is Vendor List

 


my parameter is called Vendorname 

 

 

 

let
  	
vendorListSelected = if Type.Is(Value.Type("VendorName"),List.Type) then
  Text.Combine({"'", Text.Combine(vendorList,"','"), "'"})
  else Text.Combine({"'",VendorName,"'"}),

vendorListAll = if Type.Is(Value.Type("VendorName"),List.Type) then 
  List.Contains(VendorName, "all") else 
  false,

query = "Select lower(rtt.username) as ""userid"",#(lf)upper(fc.vendororganizationname) as Vendor,#(lf)rtt.sessionkey as ""Session Key"",#(lf)rtt.roundtriptime as ""Latency"",#(lf)rtt.sessionstarttime,#(lf)Date(rtt.sessionstarttime) as dateonly,#(lf)time(date_trunc('minute',rtt.sessionstarttime)) as timeonly#(lf)from eux_prd_eudl_db.ctx_views.ctx_sessionrtt_utc rtt#(lf)join eux_prd_eudl_db.ctx_landing.sg_full_contractorexpress fc on lower(rtt.username) = lower(fc.domainuserid)#(lf)where fc.vendororganizationname <> 'null' and length(fc.vendororganizationname) > 1#(lf)and fc.vendororganizationname is not null and rtt.username is not null and length(rtt.username) > 1 and (length(rtt.sessionkey) > 1)#(lf)and rtt.sessionstarttime >= dateadd('DAY',-14, current_date)",

filter = if vendorListAll then " "
            else Text.Combine({" AND upper(FC.VENDORORGANIZATIONNAME) IN (", vendorList, ")"}),

finalquery = Text.Combine({query,filter}),
      
    Source = Value.NativeQuery(Snowflake.Databases("uhgdwaas.east-us-2.azure.snowflakecomputing.com","EUX_PRD_CTX_LOADER_MEDIUM_WH"){[Name="EUX_PRD_EUDL_DB"]}[Data], finalquery, null, [EnableFolding=true])
in
    Source