cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Ahmedelshark
Helper I
Helper I

Card Visual to display number of months from date range slicer

Hello,

 

I am trying to write a measure that will display the total number of months between the two dates in my date range slicer. How do I refer to the slicer itself? Or if there is a better way do this, please let me know. 

 

Thank you so much in advance.

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ahmedelshark , Create a new measure

diff between selected range =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = minx(allselected('Date'),'Date'[Date])
return
datediff(_min, _max, month)

View solution in original post

3 REPLIES 3
Bhavana832
New Member

@amitchandak 

Hi Sir, 

I am also searching on the same issue that time i found your solution , I have tried but finding an error. Could you please help me with this.

if starting date is 01-04-2022 & ending date is 31-08-2022, According to your formulae it will show 4 months in between but actually its 5(apr,may, june, july, august)

How can we solve this?

 

Thank you in adavance

amitchandak
Super User
Super User

@Ahmedelshark , Create a new measure

diff between selected range =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = minx(allselected('Date'),'Date'[Date])
return
datediff(_min, _max, month)

This worked. Thank you @amitchandak !

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors