Forum Discussion
Passing Measure output in MQuery
- Anonymous1 year ago
v-dineshya Thanks for checking. We have done it in other way. I will share it once it is done.
Right now it is required we can close this.
Hi Anonymous
Yes, you can try to replace the hardcoded 500 value with a dynamic measure from your Power BI model.
Since you're working with a DirectQuery, we need to use Power BI's parameters to pass values from your report to the SQL query.
I) Create a Parameter
In Power BI Desktop, go to Home tab ā Manage Parameters ā New Parameter
Create a parameter named CustomsValueThreshold with:
Type: Decimal Number
Suggested Values: List of values or Any value
Default value: 500 (or whatever you prefer)
II) Modify your query
let
ThresholdValue = Text.From(Parameter1), // Convert parameter to text for SQL
Source = Sql.Database(
"euwdfas0rssql01.database.windows.net",
"EUWDFAS0RSSDB01",
[Query="
SELECT
HsCode,
SUM(SupplementaryUnitQty) AS TotalSupplementaryUnitQty
FROM
[dbo].[CBAM_Goods_InScope]
WHERE
[EntryIdentifier] IN (
SELECT [EntryIdentifier]
FROM [dbo].[CBAM_Goods_InScope]
GROUP BY [EntryIdentifier]
HAVING SUM([CustomsValue]) > " & ThresholdValue & "
)
GROUP BY
HsCode;"
])
in
Source
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" ā Iād truly appreciate it!
Thank you.