Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to figure out if it would be possible to create a variable in my PowerBI query to replace a portion of my query.
What I'm ultimately trying to do, is to have a popdown menu in my PowerBI report that allows me to select the tenant name which associates with a particular tenantID.
I created a new table that contains "Tenant Name" and "TenantID fields" and added a slicer to select the Tenant.
What I'd like to do next is if "Tenant Name X" is selected on the slicer, have the TenantID fetched from that table and replaced in my query so that the correct data can be pulled.
Now sure if that's possible like it would in SQL but am hoping that something similar can be setup.
= let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/TENANTID/query",
[Query=[#"query"="WaaSDeploymentStatus",#"x-ms-app"="OmsAnalyticsPBI",#"timespan"="all",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0)])),
TypeMap = #table(
{ "AnalyticsTypes", "Type" },
{
{ "string", Text.Type },
{ "int", Int32.Type },
{ "long", Int64.Type },
{ "real", Double.Type },
{ "timespan", Duration.Type },
{ "datetime", DateTimeZone.Type },
{ "bool", Logical.Type },
{ "guid", Text.Type }
}),
DataTable = Source[tables]{0},
Columns = Table.FromRecords(DataTable[columns]),
ColumnsWithType = Table.Join(Columns, {"type"}, TypeMap , {"AnalyticsTypes"}),
Rows = Table.FromRows(DataTable[rows], Columns[name]),
Table = Table.TransformColumnTypes(Rows, Table.ToList(ColumnsWithType, (c) => { c{0}, c{3}}))
in
Table
Solved! Go to Solution.
Hi @samw5 ,
Please create query parameter to change the data source dynamically instead of using slicer selection, you can refer the following documentations to achieve it.
Change the Source of Power BI Datasets Dynamically Using Power Query Parameters
Dynamic Web.Contents() and Power BI Refresh Errors
Web.Contents with dynamic file URL
Best Regards
Rena
@samw5 , not clear, refer if this can help
https://www.biinsight.com/power-bi-desktop-query-parameters-part-1/
So i have data from 2 tables being fetched from Azure.
I created a 3rd table with Name and ID columns.
What I'm trying to do, is to setup a slicer on my visualization that will allow me to pick the "Name", then use the "ID" as a variable into my 2 other tables.
@samw5 - So, you should just have to use this in your measure:
VAR __ID = MAX('Third Table'[ID])
Since you select a name, that will filter that third table to that name so the MAX will get the associated ID.
OK now while the filter would work, how could I possibly (not sure if that can even be done) use that ID value back into the original 2 tables queries?
That VAR_ID would need to somehow be inserted into my query. Not sure how to do that.
= let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/VAR_ID/query"
Hi @samw5 ,
Please create query parameter to change the data source dynamically instead of using slicer selection, you can refer the following documentations to achieve it.
Change the Source of Power BI Datasets Dynamically Using Power Query Parameters
Dynamic Web.Contents() and Power BI Refresh Errors
Web.Contents with dynamic file URL
Best Regards
Rena
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
96 | |
80 | |
67 | |
62 |
User | Count |
---|---|
138 | |
107 | |
104 | |
82 | |
63 |