- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

How to calculate the date difference between a existing column with date slicer "selected value"
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 05:20 AM
Hi ALL,
I have a table with two date columns "ValueDate" and "EOMDate" (end of month date), I have taken the EOMDate in a date slicer and also able to capture the value selected from the slicer using below code with a Measure as below.
ValueSelected = CALCULATE( MAX(Remittance[Remittance.EOMDate]), ALLSELECTED(Remittance[Remittance.EOMDate]))
but I am unable to compare the measure "ValueSelected" with column "ValueDate".
I tried this first
AgeMeasure = DATEDIFF(Remittance[Remittance.ValueDate],Remittance[ValueSelected],DAY)
I got the below error
"A single value for column 'Remittance.ValueDate' in table 'Remittance' 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 tired the below as an alternative approach, which is throughing the same error , any advise will be much helpful.. Hearty thanks.
AgeMeasure = VAR MinVDate = MIN(Remittance[Remittance.ValueDate]) VAR MinVVD = DATEDIFF(MinVDate,Remittance[Remittance.ValueDate],DAY) // Getting the error Here VAR SVMVD = DATEDIFF(MinVDate,[ValueSelected],DAY) RETURN SVMVD - MinVVD
Solved! Go to Solution.
Accepted Solutions
Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 11:58 AM
It's not clear to me what you are trying to do here. What a slicer does is filter your table. The best way to understand this is to load your data into Excel, convert it to a table and then place a filter on the EOM column for the date you want. This is what a slicer does. Now that the table is filtered, what do you want to do? The table has a filter on it so you are limited in what you can do to the filtered copy of the table.
So, still not really knowing what you want to do, it is likely that you will need 1 or 2 disconnected slicers that are on a table of dates. Click on this new slicer to harvest the value that the user selects. This way you get the input without placing a filter on the table.
If you can provide some more information about the logic of what you are trying to acheive I could possibly help some more
All Replies

Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 05:28 AM
Example Data
EOMDate | ValueDate | SelectedDate |
12/31/2012 | 12/06/2012 | 10/31/2016 |
02/28/2013 | 02/21/2013 | 10/31/2016 |
08/31/2014 | 08/18/2014 | 10/31/2016 |
09/30/2014 | 09/14/2014 | 10/31/2016 |
Expected Output
EOMDate | ValueDate | SelectedDate | AgeValue |
12/31/2012 | 12/06/2012 | 10/31/2016 | 1425 |
02/28/2013 | 02/21/2013 | 10/31/2016 | 1348 |
08/31/2014 | 08/18/2014 | 10/31/2016 | 805 |
09/30/2014 | 09/14/2014 | 10/31/2016 | 778 |
Note:
ValueDate: >> Column from the Source (SSAS Tabular model)
SelectedDate / ValueSelected : >> a measure calculated based on the date slicer built on "EOMDate" column

Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 06:46 AM
@MattAllington, could you please help me on this ..

Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 06:48 AM
@MattAllington, @Greg_Decklercould you please help me on this ..
Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 11:58 AM
It's not clear to me what you are trying to do here. What a slicer does is filter your table. The best way to understand this is to load your data into Excel, convert it to a table and then place a filter on the EOM column for the date you want. This is what a slicer does. Now that the table is filtered, what do you want to do? The table has a filter on it so you are limited in what you can do to the filtered copy of the table.
So, still not really knowing what you want to do, it is likely that you will need 1 or 2 disconnected slicers that are on a table of dates. Click on this new slicer to harvest the value that the user selects. This way you get the input without placing a filter on the table.
If you can provide some more information about the logic of what you are trying to acheive I could possibly help some more
Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-20-2018 11:34 PM
Hi @Anonymous,
Actually, you don't want to filter the data. You'd like to indicate the date instead. I would suggest you create a new table [EOMDate] that will provide the field of the slicer.
Please download the demo from the attachment.
SelectedValue = SELECTEDVALUE('Table'[EOMDate])
Measure = DATEDIFF ( MIN ( 'Table1'[ValueDate] ), [SelectedValue], DAY )
Best Regards,
Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-21-2018 02:58 AM
Hi @v-jiascu-msft,
Thanks for your Great time.. it is working fine with "List" and "Dropdown" type of date slicer, but for my requirement I am using "Before" type of slicer where this "SelectedValue" is not working..
unfortunately, I need to filter the data to get whatever data available Prior to the date (EOMDate) as per the selection
any help is much & more appreciated..
Thanks,
Prabhu

Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-21-2018 03:20 AM
Hi @MattAllington,
Thanks for your kind response,
all I want to achieve is,
1) Need to filter the table based on the slicer selection (condition is to get the data prior to the date selected)
2) Need to find the date difference (age value ) from the date selected through "Before" date slicer.
hope this clarifies your doubts..
Thanks,
Prabhu
Re: How to calculate the date difference between a existing column with date slicer "selected v
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-23-2018 05:55 PM
Hi @Anonymous,
It's my pleasure. The measure could be useful in many scenarios. Please try it out.
SelectedValue = Max('Table'[EOMDate])
Best Regards,
Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.