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
gebhaarde
New Member

DATEADD with slicer parameter

I have a table with the following example data:

NATUREDATE1
NOTEBOOK2016.01.01

I would like to add a column, which is generated based on these:

If the NATURE column has "NOTEBOOK" in it, add X years to DATE1 column.

X value is depended on a slicer value which you can choose in the visualization.

I was trying to do this with several methods, but nothing seems to work.

Can you help?

 

Thanks.

1 ACCEPTED SOLUTION

Hi @gebhaarde 

try this, create the measure

date2 = 
var _addY=SELECTEDVALUE(Slicer[Rollout years])
var _year=EDATE(MIN('Table'[date1]),_addY*12)
return _year

result

vxiaotang_0-1639374804157.png

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@gebhaarde , You need to create create a measure

datediff(max(Table[Date1]) ,maxx(allselected(date),date[date]), day)

 

In case you want to add or avg

 

you need

sumx(values(Table[NATURE]), datediff(max(Table[Date1]) ,maxx(allselected(date),date[date]), day)  )

@amitchandak Unfortunately, this isn't working.

Maybe I wasn't clear, let me reelaborate, this is my data source:

inventory numbernaturedate1date2
a1NOTEBOOK2016.01.01. 
a2MOBILE2017.02.01 
a3NOTEBOOK2019.05.01. 

I would like to calculate a column "date2" (or a measure if its better) that adds X years to "date1" column.

The value X is chosen with a slicer like this:

gebhaarde_0-1639043437563.png

So if I set 3 years in the slicer, the first row's date2 column would be 2019.01.01, but if I set 3.5 or 4 years, the date2 column would update accordingly.

My final goal is to count these values by inventory numbers in a matrix visualsation according to date2.

Thanks in advance!

Hi @gebhaarde 

try this, create the measure

date2 = 
var _addY=SELECTEDVALUE(Slicer[Rollout years])
var _year=EDATE(MIN('Table'[date1]),_addY*12)
return _year

result

vxiaotang_0-1639374804157.png

 

Best Regards,

Community Support Team _Tang

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

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.