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
MarieJ
Regular Visitor

how to get min & max date from date slider and make it as filter value?

 Hello, genius!

 

I have some problems like below,

I want to make "From Date"  and "To Date" from Date slider as filter value.

But once I want to make them as filter values, it doesn't work.

 

Inventory($) is Sum of Inventory between Date slider.

F.D Inv($) should be Sum of Inventory at only From Date (12/26/2016),

but it's the same as Inventory($) between Date slider.

T.D Inv(S) should be Sum of Inventory at only To Date (12/18/2017),

but it's the same as Inventory($) between Date slider.

 

The measure formulas are like below red lines.

why does this happen? T.T

 image.png

 

 

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

Hi @MarieJ,

 

Here I made a test to meet your requirement.
At first, create a dimtime table using DAX below and create relationship between table1 and dimtime table.

 

Dimtime = CALENDARAUTO()

 

Then create the measures in table1 as below:

 

from Date = CALCULATE(MIN(Dimtime[Date]),ALLSELECTED(Dimtime[Date]))
To Date = CALCULATE(MAX(Dimtime[Date]),ALLSELECTED(Dimtime[Date]))
T.D Inv($) = CALCULATE(SUM(Table1[Inventory]),FILTER(ALLSELECTED(Table1[Date]),Table1[Date]=[To Date]))
F.D Inv($) = CALCULATE(SUM(Table1[Inventory]),FILTER(ALLSELECTED(Table1[Date]),Table1[Date]=[from Date]))

 

Then we can create date slicer using date field of dimtime table and get the result as below.

 

1.PNG

 

For more information, please check the pbix as attached.

 

https://www.dropbox.com/s/0xqnma3e45moifx/how%20to%20get2.pbix?dl=0

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @MarieJ,

 

Here I made a test to meet your requirement.
At first, create a dimtime table using DAX below and create relationship between table1 and dimtime table.

 

Dimtime = CALENDARAUTO()

 

Then create the measures in table1 as below:

 

from Date = CALCULATE(MIN(Dimtime[Date]),ALLSELECTED(Dimtime[Date]))
To Date = CALCULATE(MAX(Dimtime[Date]),ALLSELECTED(Dimtime[Date]))
T.D Inv($) = CALCULATE(SUM(Table1[Inventory]),FILTER(ALLSELECTED(Table1[Date]),Table1[Date]=[To Date]))
F.D Inv($) = CALCULATE(SUM(Table1[Inventory]),FILTER(ALLSELECTED(Table1[Date]),Table1[Date]=[from Date]))

 

Then we can create date slicer using date field of dimtime table and get the result as below.

 

1.PNG

 

For more information, please check the pbix as attached.

 

https://www.dropbox.com/s/0xqnma3e45moifx/how%20to%20get2.pbix?dl=0

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Oh My God! 

You're the genius to save my days!

Thank you so much!!

 

The problem was "ALLSELECTED"!!

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.