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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
nehajadhav166
Resolver I
Resolver I

Get selected value from date slicer

Hi Experts,

 

I have date slicer like this

nehajadhav166_0-1661862012204.png

When I select value from slicer I want to capture that date range. I want to use this date range as part of other measure filter.

nehajadhav166_1-1661862074771.png

For example I want date range 1/10/2022 to 6/12/2022 and not min and max dates.

I tried selected value function but it did not work.

Any pointers here?

 

Thanks in advance.

 

Regards,

Neha

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @nehajadhav166 ,

Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1662088854830.png

Date Table(create from "Table" with dax):

 

Date Table = CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]))

 

vbinbinyumsft_1-1662088888510.png

Model:

vbinbinyumsft_2-1662088906781.png

2. add a slicer with "Date Table[Date]",create a measure and add it to card visual

 

Sum for Sales =
VAR maxdate =
    MAXX ( ALLSELECTED ( 'Date Table'[Date] ), [Date] )
VAR mindate =
    MINX ( ALLSELECTED ( 'Date Table' ), [Date] )
VAR tmp =
    CALENDAR ( mindate, maxdate )
RETURN
    CALCULATE ( SUM ( 'Table'[Sales] ), tmp )

 

Animation9.gif

Please refer the attached .pbix file.

Best regards,
Community Support Team_ Binbin Yu
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

4 REPLIES 4
v-binbinyu-msft
Community Support
Community Support

Hi @nehajadhav166 ,

Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1662088854830.png

Date Table(create from "Table" with dax):

 

Date Table = CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]))

 

vbinbinyumsft_1-1662088888510.png

Model:

vbinbinyumsft_2-1662088906781.png

2. add a slicer with "Date Table[Date]",create a measure and add it to card visual

 

Sum for Sales =
VAR maxdate =
    MAXX ( ALLSELECTED ( 'Date Table'[Date] ), [Date] )
VAR mindate =
    MINX ( ALLSELECTED ( 'Date Table' ), [Date] )
VAR tmp =
    CALENDAR ( mindate, maxdate )
RETURN
    CALCULATE ( SUM ( 'Table'[Sales] ), tmp )

 

Animation9.gif

Please refer the attached .pbix file.

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-binbinyu-msft ,

Thank you for reply.

I tried this approch and it worked for me.

Var selected_maxdate=IF.EAGER( (ISFILTERED ( 'TestData'[Date] )),MAX ( 'TestData'[Date] ),MAX(TestData[Date]))
Var selected_mindate=IF.EAGER( (ISFILTERED ( 'TestData'[Date] )),MIN ( 'TestData'[Date] ),MIN(TestData[Date]))
 
Allselected and min/max did not wor for me.
Thanks,
Neha
nehajadhav166
Resolver I
Resolver I

Hi Amit,

Thanks for quick reply.

I do not understand how countrows will help to get values selected from date slicer?

Can you please elaborate?

 

Thanks,

Neha

amitchandak
Super User
Super User

@nehajadhav166 ,

 

Measure =

var _tab = values(date[Date])

return

countrows(filter(Table, Table[Date] in _tab) )

 

Or between

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors