Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello everybody.
I'm quite new ot PowerBI.
I try and fail doing this in power Query on Power BI.
I try and fail to find a exemple of this.
I have a BD Snapshot (that have all the snapshot from lot BDs and Tables).
In the Snapshot reference table I have "date_of_snapshot" and "SnapshotID".
And all the tables have a column "SnapshotID"
What I want to do, is simple, take the "SnapshotID" related to the most recent "date_of_snapshot" and get all other query of to load only the data related to this last "SnapshotID".
Thanks stranger for your help
Solved! Go to Solution.
For future reference :
let
Source = Sql.Database("MyDataBase.local", "DataWarehouse", [HierarchicalNavigation=true, MultiSubnetFailover=true, Query="
Declare @SnapID VARCHAR(MAX);
Declare @Instruction VARCHAR(MAX);
SET @SnapID = (SELECT TOP (1) SnapShotId FROM [DataWarehouse].[dbo].[Snapshots] ORDER BY EndedOn DESC);
SELECT * FROM [DataWarehouse].[dbo].[MyTable] Where SnapshotId in (@SnapID)"])
in
SourceSo simple, but so research 😉
In MS-SSMS I can do this :
SELECT TOP (1) * FROM [DataWarehouse].[dbo].[Snapshots] ORDER BY EndedOn DESC
but when I try this :
let
Source = Sql.Database("mydatabase.local", "DataWarehouse", Query="SELECT TOP (1) * FROM [DataWarehouse].[dbo].[Snapshots] ORDER BY EndedOn DESC"),
dbo_Snapshots = Source{[Schema="dbo",Item="Snapshots"]}[Data]
in
dbo_SnapshotsI got no result in PowerBI.
So I think I mess somewhere, but I can find it.
let
Source = Sql.Database("mydatabase.local", "DataWarehouse", [Query="SELECT TOP (1) * FROM [DataWarehouse].[dbo].[Snapshots] ORDER BY EndedOn DESC"]),
dbo_Snapshots = Source{[Schema="dbo",Item="Snapshots"]}[Data]
in
dbo_SnapshotsFor some how, you need to write [ query ] didn't see this documented, but that how the automatic generation work.
Now, I just need to find how my other select can union with the snapshot ID.
For future reference :
let
Source = Sql.Database("MyDataBase.local", "DataWarehouse", [HierarchicalNavigation=true, MultiSubnetFailover=true, Query="
Declare @SnapID VARCHAR(MAX);
Declare @Instruction VARCHAR(MAX);
SET @SnapID = (SELECT TOP (1) SnapShotId FROM [DataWarehouse].[dbo].[Snapshots] ORDER BY EndedOn DESC);
SELECT * FROM [DataWarehouse].[dbo].[MyTable] Where SnapshotId in (@SnapID)"])
in
SourceSo simple, but so research 😉
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 7 | |
| 5 | |
| 5 | |
| 3 |