cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jacob1832
Frequent Visitor

Dax IF() formula referring to a dynamic Date selection.

I would like to calculate a field in Dax (some equlilvant would be great) that references a dynamic DATE parameter. The column would output text, but that text change if the date changed.
Example:

Col = if(1stDateThatAlreadyExists >  DateParamater, "XXXX", if(2ndDateThatAlreadyExists > DateParamater && 1stDateThatAlreadyExists<= DateParamater, "YYYY", ......

So the idea is that this column would compare a date field that already exists in my data to a date field that can change, and thus change the output for the column
Note: All date fields that i would compare the parameter against were calculated in dax


1 ACCEPTED SOLUTION

Hi @Jacob1832 ,

Please refer to the blog to see if it helps you.

Field Parameters in Power BI - Microsoft Power BI Community

If you want to dynamically switch values, we can also use the SWITCH TRUE method. However, the value returned by the SWITCH TRUE method can only be in one format, and Field Parameters can dynamically display values in different formats.

 

In short, Field parameters enable dynamic dimensions and calculations, Including: dynamic axis, dynamic legend and dynamic value.

Field parameters are useful because they allow users to seamlessly change the columns used in visual objects. Field parameters can provide a very customizable user experience.

 

Best Regards

Community Support Team _ Polly

 

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

4 REPLIES 4
v-polly-msft
Community Support
Community Support

Hi @Jacob1832 ,

There is nothing error with the formula. Could you please provide more details with the desired output?

Could you please provide your pbix file without privacy information and desired output with more details?

 

How to Get Your Question Answered Quickly 

 

Best Regards

Community Support Team _ Polly

 

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

 

 

@v-polly-msf
Im am thinking of a what-if paramater like the built in one, but for a date field that i could then reference in an IF statment on a table, and the output of that if statment would change if i change the parameter date. 

Jacob1832_1-1668098995452.png

 

 

Hi @Jacob1832 ,

Please refer to the blog to see if it helps you.

Field Parameters in Power BI - Microsoft Power BI Community

If you want to dynamically switch values, we can also use the SWITCH TRUE method. However, the value returned by the SWITCH TRUE method can only be in one format, and Field Parameters can dynamically display values in different formats.

 

In short, Field parameters enable dynamic dimensions and calculations, Including: dynamic axis, dynamic legend and dynamic value.

Field parameters are useful because they allow users to seamlessly change the columns used in visual objects. Field parameters can provide a very customizable user experience.

 

Best Regards

Community Support Team _ Polly

 

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

I will work on a sharable PBIX file. I should have been clearer. I dont know how to create the dynamic DateParamater in a way that will change the output of the column when i change the date. The desired output of the formula is a text string. And that text string should change when i change the DateParamater. I dont know how to create the date parameter. Do I create a new table? How do i connect it to the table the formula resides in so it can reference the date? If i connect it, wouldnt the connection filter override the if statement?

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.