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
Shackwell
Helper III
Helper III

Using filters in a table with measures

Hello,

 

I have a database of a the last year and Im looking to create a measure that shows the cummulative cost from month to month. For example.

I require a measure that can sum with some sort of cummulative filters. Like having a filter to calculate the cost up until may 2020, or calculate all the costs up until aug 2020 or dec 2020.  I tried using a filter but was only showing individual months (for example was showing only the costs in september, and Im looking to see all the costs from january to september.

Thank you for your time.

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @Shackwell 

 

Download sample PBIX file with the following code and visuals.

 

SumCost = SUM('DataTable'[Cost])

 

You can use a slicer for the dates, set to 'Between', so you get a slider that you can select dates with.  The cost is then affected by the selected date range.

slicer2.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @Shackwell ,

 

First create a calendar table as slicer;

Then create a measure as below:

 

Measure = 
var _dates=DATESYTD('calendar'[Date])
Return
IF(MAX('DataTable'[Date]) in _dates,SUM('DataTable'[Cost]),BLANK())

 

And you will see:

vkellymsft_0-1633414595478.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @Shackwell ,

 

First create a calendar table as slicer;

Then create a measure as below:

 

Measure = 
var _dates=DATESYTD('calendar'[Date])
Return
IF(MAX('DataTable'[Date]) in _dates,SUM('DataTable'[Cost]),BLANK())

 

And you will see:

vkellymsft_0-1633414595478.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

 

PhilipTreacy
Super User
Super User

Hi @Shackwell 

 

Download sample PBIX file with the following code and visuals.

 

SumCost = SUM('DataTable'[Cost])

 

You can use a slicer for the dates, set to 'Between', so you get a slider that you can select dates with.  The cost is then affected by the selected date range.

slicer2.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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.