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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
niel_orvyn1
Helper III
Helper III

Calculating (Sum) when using a between date slicer: Calculate between values only

Hi there,

I want to display the total value for a month by using the between slicer.
However, when I try and make it easier for the user so the user can select from the first of the montht the 1st of the second month I gives me the total for both months.

 

Between slicer example.jpg

Any ideas to change measure or do I have to change my approach? 

I will use the same page to insert SAMEPERIODASLATYEAR and add an KPI card. 

 

Many thanks.

 

Rgds,

Niel

2 ACCEPTED SOLUTIONS
AllisonKennedy
Super User
Super User

Do you just want them to select a single month? If so I suggest using a Month slicer, with the month from your DimDate table if you have one:
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

amitchandak
Super User
Super User

@niel_orvyn1 , Try to have separate date table Try

measure =
var _max = eomonth(maxx(allselected(Date),Table[Date]),0)
var _min = eomonth(minx(allselected(Date),Table[Date]),-1)+1

return
calculate(sum(Tbale[value]),filter(all(Table[Date]), Table[Date] >=_min && Table[Date] <=_max))


measure =
var _max = eomonth(maxx(allselected(Date),Table[Date]),0)
var _min = eomonth(minx(allselected(Date),Table[Date]),-1)+1

return
calculate(sum(Tbale[value]),filter(all(Date[Date]), Date[Date] >=_min && Table[Date] <=_max))

 

 

So time this can group data into few dates. if that happens refer to this video

https://www.youtube.com/watch?v=duMSovyosXE

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@niel_orvyn1 , Try to have separate date table Try

measure =
var _max = eomonth(maxx(allselected(Date),Table[Date]),0)
var _min = eomonth(minx(allselected(Date),Table[Date]),-1)+1

return
calculate(sum(Tbale[value]),filter(all(Table[Date]), Table[Date] >=_min && Table[Date] <=_max))


measure =
var _max = eomonth(maxx(allselected(Date),Table[Date]),0)
var _min = eomonth(minx(allselected(Date),Table[Date]),-1)+1

return
calculate(sum(Tbale[value]),filter(all(Date[Date]), Date[Date] >=_min && Table[Date] <=_max))

 

 

So time this can group data into few dates. if that happens refer to this video

https://www.youtube.com/watch?v=duMSovyosXE

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
AllisonKennedy
Super User
Super User

Do you just want them to select a single month? If so I suggest using a Month slicer, with the month from your DimDate table if you have one:
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy  and  @amitchandak 

 

Many thanks for both your replies and help. Adding a dimdate table solved my problem, previously I was using the date from the original table😞

 

Best Regards,

 

Niel

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.