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
Anonymous
Not applicable

calculating qty for previous months wrt to selected date in slicer

Hi,
if
i select 9/10/2019 in slicer as aboveVenkat_Official_0-1572354128262.png
the below is measure for getting qty between starting of that month(9/1/2019 to 9/10/2019) 
Measure = CALCULATE([Quantity],DATESBETWEEN('Calendar'[Date],STARTOFMONTH('Calendar'[Date]),LASTDATE('Calendar'[Date])))
 
in the same way i also has to get last months qty i.e (8/1/2019 to 8/10/2019), (7/1/2019 to 7/10/2019), (6/1/2019 to 6/10/2019) as shown in below
Venkat_Official_2-1572354651806.png
 
Thank you.
 
 
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Mariusz's suggestion should be useful.

If you need a date slicer to be selected, then you could create a date table which has no relationship with your main data table.

then use the "date" column from this table to a slicer.

date table = CALENDARAUTO()

Then create measures

selected date = MAX('date table'[Date])

Measure = CALCULATE(SUM(Sheet7[value]),FILTER(Sheet7,DAY(Sheet7[date])<=DAY([selected date])))

Capture19.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

To your visual, drag month from the Calendar Table.  Also, ensure that the Date slicer is built from the Calendar Table.  Try this measure

=CALCULATE([Quantity],DATESBETWEEN(Calendar[Date],EOMONTH(MIN(Calendar[Date]),-2)+1,EDATE(MIN(Calendar[Date]),-1)))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Mariusz's suggestion should be useful.

If you need a date slicer to be selected, then you could create a date table which has no relationship with your main data table.

then use the "date" column from this table to a slicer.

date table = CALENDARAUTO()

Then create measures

selected date = MAX('date table'[Date])

Measure = CALCULATE(SUM(Sheet7[value]),FILTER(Sheet7,DAY(Sheet7[date])<=DAY([selected date])))

Capture19.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can add a Day column into your calendar table and use it as slicer like below.

image.png

 

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

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.

Top Solution Authors