cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ravsha85
Helper IV
Helper IV

Passing Parameters in measures

Hi,

Thanks everyone for the comments for my previos posts.

I have one more question which I would like to clarify, Is there a way to parameterize values in Measures.

For eg: I have created a measure like below in which I would like to parametrize the Yearmonth value(highlighted), pls let me know even if we have any workarounds for this.

 

Total Sales = CALCULATE(
SUM('Headcount Data'[May-17]),
FILTER(Year_Month,Year_Month[Year_Month]=201705)
)

 

Regards,

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft
Microsoft

@ravsha85,

 

Currently, we cannot use a parameter in a calculated 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. Sample parameter.
    Capture.PNG
  2. Create a blank query and edit the query in Advanced Editor
    Capture1.PNGCapture2.PNG
  3. Create a measure in your original table like below.
    Total Sales = CALCULATE(
    SUM('Headcount Data'[May-17]),
    FILTER(Year_Month,Year_Month[Year_Month]=Max(Query2[ParameterDate]))
    )

Regards,

Chalrie Liao

 

 

View solution in original post

3 REPLIES 3
smrtboy89
New Member

Hi,

 

Does anyone know is the opposite is possible? Can I store the value of a measure into a parameter?

v-caliao-msft
Microsoft
Microsoft

@ravsha85,

 

Currently, we cannot use a parameter in a calculated 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. Sample parameter.
    Capture.PNG
  2. Create a blank query and edit the query in Advanced Editor
    Capture1.PNGCapture2.PNG
  3. Create a measure in your original table like below.
    Total Sales = CALCULATE(
    SUM('Headcount Data'[May-17]),
    FILTER(Year_Month,Year_Month[Year_Month]=Max(Query2[ParameterDate]))
    )

Regards,

Chalrie Liao

 

 

Phil_Seamark
Microsoft
Microsoft

Hi @ravsha85

 

You could always use another measure for this. 

 

eg create a calculated measure like this.  You could even create a measure table called My Parameters to group them all together.

 

My Param = 201705

and then drop this into your other formula

 

Total Sales = CALCULATE(
SUM('Headcount Data'[May-17]),
FILTER(Year_Month,Year_Month[Year_Month]=[My Param])
)
 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 episode 5 with aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt will talk about the importance of Data Modeling.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!