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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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-rongtiep-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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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