The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi Experts,
I have date slicer like this
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.
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
Solved! Go to Solution.
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:
Date Table(create from "Table" with dax):
Date Table = CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]))
Model:
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 )
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.
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:
Date Table(create from "Table" with dax):
Date Table = CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]))
Model:
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 )
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.
Thank you for reply.
I tried this approch and it worked for me.
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
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))
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
139 | |
112 | |
108 | |
72 | |
58 |
User | Count |
---|---|
263 | |
131 | |
123 | |
100 | |
96 |