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
spmivilsoftbi
New Member

Function DAX To parameter

Hello,

I have a DAX function that returns the minimum and maximum date of a list of dates

 

Date_Init = CALCULATE(MIN(filters_1[Date]), ALLSELECTED(filters_1))
Date_End = CALCULATE(MAX(filters_1[Date]), ALLSELECTED(filters_1))

 

But when I want to bind a parameter to those functions, the Power Bi app doesn't give me the option to do so.

Is there a way to bind those DAX functions to parameters? Is there another way to do it?

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @spmivilsoftbi ,

 

May I know how you want to bind these function to your parameters? What kind of parameters do you want to bind?

If you define your parameter by New Parameter feature, you could directly use it to do calculation. If your parameter is defined in Power Query Editor(Transform data), you could load it to your model and use it to some calculations in your formula or take it to make a visual just like other fields.

vcazhengmsft_0-1650526870048.png

 

And normally, if you would like to take your parameter value into your formula, you could use SELECTEDVALUE/MAX/MIN in measure or directly use the field name of the parameter in Calculated column. So you could make a little bit change to your formulas like this.

 

Date_Init = CALCULATE(MIN(filters_1[Date]), FILTER( ALLSELECTED(filters_1),'filters_1'[column name]=SELECTEDVALUE(Your parameter name)))

Date_End = CALCULATE(MAX(filters_1[Date]), FILTER( ALLSELECTED(filters_1), 'filters_1'[column name]=SELECTEDVALUE(Your parameter name)))

 

 

Here are the official document about these funcitons.

SELECTEDVALUE function - DAX | Microsoft Docs

MIN function (DAX) - DAX | Microsoft Docs

MAX function (DAX) - DAX | Microsoft Docs  

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

2 REPLIES 2
v-cazheng-msft
Community Support
Community Support

Hi @spmivilsoftbi ,

 

May I know how you want to bind these function to your parameters? What kind of parameters do you want to bind?

If you define your parameter by New Parameter feature, you could directly use it to do calculation. If your parameter is defined in Power Query Editor(Transform data), you could load it to your model and use it to some calculations in your formula or take it to make a visual just like other fields.

vcazhengmsft_0-1650526870048.png

 

And normally, if you would like to take your parameter value into your formula, you could use SELECTEDVALUE/MAX/MIN in measure or directly use the field name of the parameter in Calculated column. So you could make a little bit change to your formulas like this.

 

Date_Init = CALCULATE(MIN(filters_1[Date]), FILTER( ALLSELECTED(filters_1),'filters_1'[column name]=SELECTEDVALUE(Your parameter name)))

Date_End = CALCULATE(MAX(filters_1[Date]), FILTER( ALLSELECTED(filters_1), 'filters_1'[column name]=SELECTEDVALUE(Your parameter name)))

 

 

Here are the official document about these funcitons.

SELECTEDVALUE function - DAX | Microsoft Docs

MIN function (DAX) - DAX | Microsoft Docs

MAX function (DAX) - DAX | Microsoft Docs  

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

karnold
Resolver I
Resolver I

You cannot use DAX measures as Power Query parameters. You could determine the values in PQ and use them in a different table.

 

 

let
    Source = filters_1,
    MinValue = Table.Min(Source,"Date"),
    Result = MinValue[Date]
in
    Result

 

 

Table.Min - PowerQuery M | Microsoft Docs

Table.Max - PowerQuery M | Microsoft Docs

Helpful resources

Announcements
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.

Top Solution Authors