Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply

Need help with using parameter in measure

How can I use a Parameter in measure 

Per Asset = CALCULATE(
    AVERAGE('cbdb alarm_occurences'[qty_alarms_7day]),
    'cbdb alarm_occurences'[grid_element_key]
        IN { "75e76b7c-19f3-4119-a043-859331e74c12" }
 
need to pass "75e76b7c-19f3-4119-a043-859331e74c12" as a parameter.
Can someone please help!!
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @parvathisuku_90 ,

 

We cannot use a parameter in a measure directly. To work around this requirement, we could create a query to store parameter value in a dataset, and then use this dataset value in your calculated measure. Please refer to the sample steps below.

 

1.Create a parameter in the Power Query Editor.

屏幕截图 2020-09-23 175159.png

 

2.Create a blank query and edit the query in Advanced Editor.

屏幕截图 2020-09-23 181205.png屏幕截图 2020-09-23 181036.png

 

3.Create a measure in your original table like below.

Per Asset = CALCULATE(
    AVERAGE('cbdb alarm_occurences'[qty_alarms_7day]),
    'cbdb alarm_occurences'[grid_element_key]=Max(Query1[Parameter]))
 
 
 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @parvathisuku_90 ,

 

We cannot use a parameter in a measure directly. To work around this requirement, we could create a query to store parameter value in a dataset, and then use this dataset value in your calculated measure. Please refer to the sample steps below.

 

1.Create a parameter in the Power Query Editor.

屏幕截图 2020-09-23 175159.png

 

2.Create a blank query and edit the query in Advanced Editor.

屏幕截图 2020-09-23 181205.png屏幕截图 2020-09-23 181036.png

 

3.Create a measure in your original table like below.

Per Asset = CALCULATE(
    AVERAGE('cbdb alarm_occurences'[qty_alarms_7day]),
    'cbdb alarm_occurences'[grid_element_key]=Max(Query1[Parameter]))
 
 
 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 
amitchandak
Super User
Super User

@parvathisuku_90 , Try like

calculate(AVERAGE('cbdb alarm_occurences'[qty_alarms_7day]),
'cbdb alarm_occurences'[grid_element_key]
IN { "75e76b7c-19f3-4119-a043-859331e74c12" })

This code is working perfectly

Per Asset = CALCULATE(
    AVERAGE('cbdb alarm_occurences'[qty_alarms_7day]),
    'cbdb alarm_occurences'[grid_element_key]
        IN { "75e76b7c-19f3-4119-a043-859331e74c12" }
But, my requirement is to pass "75e76b7c-19f3-4119-a043-859331e74c12' as a parameter to the measure. "75e76b7c-19f3-4119-a043-859331e74c12" is a sample value. I want to change this with the help of parameter.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.