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
allison_t
Frequent Visitor

Date Parameter Used in Calculations

Hi, I have a use case where I need to use a date field in calculations within a PowerBI workbook. The calculations work fine when I use a hard-coded field as the date, but I need this date to be user selected instead. I am familar with Tableau and would use a Parameter in order to achieve this there. However, I can't create a date parameter in PowerBI. My workaround was two create two parameters, a year selector & a month selector and use those to create a dynamic "date selector" field using this calculation: 

Date Selector = DATE('Year Parameter'[Year Parameter Value] ,'Month Parameter'[Month Parameter Value],31). This field is a measure since only measures can use paramters in them. When 2022 is selected for the year and 12 selected for the month, I can get this value which is great:
allison_t_0-1677880409754.png

 

The problem arises in the calculations that use this. Since the calculations are columns and not measures, they don't read the value correctly and instead appear to be using a date of 12/31/1899 no matter what is selected in the parameters. I can't change my columns to be measures instead since they really do need to be calculated at a per-line basis, and have IF statements that compare multiple dates.
 
Is there any way to have a user-input date field that can then be read correctly in calculated columns?
1 ACCEPTED SOLUTION
allison_t
Frequent Visitor

Thanks @v-yiruan-msft for the confirmation. I ended up getting something to work by creating a date table and then doing a crossjoin between my original data & the date table. Not the most performant solution, but luckily my data set is relatively small.

View solution in original post

3 REPLIES 3
allison_t
Frequent Visitor

Thanks @v-yiruan-msft for the confirmation. I ended up getting something to work by creating a date table and then doing a crossjoin between my original data & the date table. Not the most performant solution, but luckily my data set is relatively small.

Hi @allison_t ,

Thanks for your feedback and sharing your solution here. Could you please mark your post as Answered? It will help the others in the community get the solution or insight easier if they face the same problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @allison_t ,

If my understanding is correctly, it seems that you would like to create a calculated column to get a dynamic date value. If yes, I'm afraid that it can't be achievable... As the value of a calculated column is computed during data refresh and uses the current row as a context, it will not change according to the user interaction(slicer, filter, column selections etc.) in the report. Please review the following links about the difference of calculated column and measure...

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

In order to get a better understanding on your requirement and give you a suitable solution or workaround, could you please provide some raw data in your table (exclude sensitive data) with Text format, your visual Fields settings and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.