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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Is it possible to calculate difference between a dynamic date and a static date

Hi All,

 

I have a column called entry date in Table A and created a date table called DateDim having column Date. 

When I'm creating the below measure I'm getting error.

 

Measure 2 = DATEDIFF(('Process Detail'[entry_date]),'DateDim1'[Date],DAY)
Error:
A single value for column 'Date' in table 'DateDim1' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
 
So I tried to create it as a column with same logic but now I'm ending up with below error.
Error:
A single value for column 'entry_date' in table 'Process Detail' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
 
I have created the join betwwen the two tables A and DateDim. Can anyone help me how to acheive this.
Note:
I'm using the Date column from Datedim as a slicer and I need to calculate difference between days of entry date and the selected date(Slicer from datedim)
 
Thanks,
Anand
 
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you want to get the date diff between the max date of your selected date and the 'Process Detail'[entry_date], you can try my method:

  1.      You should delete the relationship between the two tables because the Slicer will affect the value displayed in the table chart if they have a relationship:

v-robertq-msft_0-1608259096717.png

 

  1.      Then you can create this measure:

Datediff =

var _selecteddate=MAXX(ALLSELECTED('DateDim'),'DateDim'[Date])

return

DATEDIFF(MAX('Process Detail'[entry_date]),_selecteddate,DAY)

  1.      Then place this measure into the table chart, you can get what you want, like this:

v-robertq-msft_1-1608259096727.png

 

And You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

2 REPLIES 2
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you want to get the date diff between the max date of your selected date and the 'Process Detail'[entry_date], you can try my method:

  1.      You should delete the relationship between the two tables because the Slicer will affect the value displayed in the table chart if they have a relationship:

v-robertq-msft_0-1608259096717.png

 

  1.      Then you can create this measure:

Datediff =

var _selecteddate=MAXX(ALLSELECTED('DateDim'),'DateDim'[Date])

return

DATEDIFF(MAX('Process Detail'[entry_date]),_selecteddate,DAY)

  1.      Then place this measure into the table chart, you can get what you want, like this:

v-robertq-msft_1-1608259096727.png

 

And You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

amitchandak
Super User
Super User

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.