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 followed this topic to apply filter on data by Stored Procedure using Parameter before data import from database
My procedure doing filter data on temp table , then showing temp table to end-user.
CREATE PROCEDURE GET_MO @P_CIC nvarchar(30) = NULL, @AddressLine1 nvarchar(60) = NULL
AS
Truncate table Pol
insert into pol
SELECT *
FROM Policies
WHERE Policies.PolicyFlag = @P_CIC
and user can check data Report successfully from Power BI Service
But Parameter value are fixed !! 😞
If you are using parameter in powerBi and wnt to change parameter value through backend of your code then you can use this script of powershell
Script:
param(
[string] $parameter="Any_Value-you-want-to-pass-in-store-procedure",
[string] $datasetId= "DatasetId-Of-report-for-which-you-want-to-update-parameter-value"
)
$password = ConvertTo-SecureString "your-powerBi-EmailId-password" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ("your-login-EmailId-of-PowerBi", $password)
Connect-PowerBIServiceAccount -Credential $Cred
$urlUpdateParams = "https://api.powerbi.com/v1.0/myorg/datasets/$($datasetId)/Default.UpdateParameters"
$newBody= @{
updateDetails=@(
@{
name="Name-Parameter-You-Have-Given-In-Report(Not talking about parameter value)"
newValue="$($parameter)"
}
)
}
$jsonBody= $newBody |ConvertTo-Json
$content = 'application/json'
write-host $urlUpdateParams
Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method POST -Body $jsonBody -ContentType $content
you just have to run this script in ur backend, if somehow you are using .net core than this code will just just fine for you
Backend Code:
var file = @"[Enter full path in which you have saved your powershell script file in your PC]";
InitialSessionState initialSessionState = InitialSessionState.CreateDefault();
initialSessionState.ExecutionPolicy = ExecutionPolicy.Unrestricted;
using Runspace runspace = RunspaceFactory.CreateRunspace(initialSessionState);
runspace.Open();
PowerShell ps = PowerShell.Create(runspace);
ps.AddScript(System.IO.File.ReadAllText(file)).AddParameter("parameter",paramValue).AddParameter("datasetId",datasetId).Invoke();
runspace.Close();
Hi @Anonymous ,
Please vote the idea up to improve Power BI and make this feature coming sooner.
Do we have any workaround for this?
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 |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |