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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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