Forum Discussion
Native SQL query for Power BI
- 3 months ago
Hi BalajiBuddha
Hi,
There are two approaches you can use — pick whichever fits your setup better:
Option 1: Native SQL Query inside Power BI Advanced Editor
Pass the full SQL logic directly in M code so the filtering happens at the source before data loads into Power BI:let SqlQuery = "SELECT * FROM ""your_schema"".""your_table"" WHERE reporting_period <= '2026-03' OR ( reporting_period >= '2026-04' AND ( ( ssid IN ('Kunshan', 'Takahama') AND country NOT IN ('Country1', 'Country2', 'Country3') ) OR ssid NOT IN ('Kunshan', 'Takahama') ) )", Source = Snowflake.Databases("your_server","your_warehouse"), DB = Source{[Name="your_database"]}[Data], Schema = DB{[Name="your_schema"]}[Data], Result = Value.NativeQuery(Schema, SqlQuery) in ResultOption 2: Create a View in Snowflake (Recommended if you have access)
This way every report using this dataset inherits the rules automatically with no changes needed in Power BI:If this response was helpful, please accept it as a solution and give kudos to support other community members
HI ,
we are using snowflake but user asking us to do the changes in the dataset so , all related reports will effect , so i want this changes in dataset.
Hi BalajiBuddha
Hi,
There are two approaches you can use — pick whichever fits your setup better:
Option 1: Native SQL Query inside Power BI Advanced Editor
Pass the full SQL logic directly in M code so the filtering happens at the source before data loads into Power BI:
let
SqlQuery =
"SELECT *
FROM ""your_schema"".""your_table""
WHERE
reporting_period <= '2026-03'
OR
(
reporting_period >= '2026-04'
AND (
(
ssid IN ('Kunshan', 'Takahama')
AND country NOT IN ('Country1', 'Country2', 'Country3')
)
OR ssid NOT IN ('Kunshan', 'Takahama')
)
)",
Source = Snowflake.Databases("your_server","your_warehouse"),
DB = Source{[Name="your_database"]}[Data],
Schema = DB{[Name="your_schema"]}[Data],
Result = Value.NativeQuery(Schema, SqlQuery)
in
Result
Option 2: Create a View in Snowflake (Recommended if you have access)
This way every report using this dataset inherits the rules automatically with no changes needed in Power BI:
If this response was helpful, please accept it as a solution and give kudos to support other community members