1

I have a SSAS tabular. I'm trying to create a expression.

The code is the next:

= Sql.Database("ServerName", "mydatabase",[Query="SELECT * FROM DW_D_AC_CERTIF_OPER_DIM"])

But when I try to process the partition it gives me the following error:

An M partition uses a data function which results in access to a data source different from those defined in the model.

Can anyone help me?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Luis
  • 11
  • 1

1 Answers1

1

In Tabular, you create data sources first. Then you reference them by name in M in place of "ServerName" in your code.

DataSources referenced in M

TheRizza
  • 1,577
  • 1
  • 10
  • 23
  • I would be very helpfull if you could give a little less blur in the m query. If I reference the predefined source... how can I subsequently specifiy the SQL query? – GerardV Mar 14 '23 at 16:56
  • You can use your code. Add the Data Source, let's say as SQLServerName. Wrap the name like this: #"name_goes_here", then just insert it in your code: =Sql.Database(#"SQLServerName", "mydatabase", [Query="SELECT * FROM DW_D_AC_CERTIF_OPER_DIM"]). – TheRizza Mar 14 '23 at 20:48
  • I have a Data Source named `SRVAPP01` and now get `Expression in partition x in table y references an unknown entity`, so that looks like a small step forward but I'm clearly still missing something. My partition is defined as (simplified): `let #"Source" = #"SRVAPP01", Query = Sql.Database(#"Source", "MyDatabaseName", [Query="SELECT * FROM myTable", CreateNavigationProperties=false, CommandTimeout=#duration(0, 0, 10, 0)]) in Query` – GerardV Mar 15 '23 at 16:00
  • 1
    Ah, found it: `let Source = #"SRVAPP01", Query = Value.NativeQuery( Source, "SELECT * FROM MyTable" ) in Query` – GerardV Mar 15 '23 at 16:18