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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Sum up amount before selected slicer date

 Hi PB Buddies, 

 

I would like to have a measure, it would sum up the amount before the selected start date with date slicer changing, 
For example, when the date slicer selected 5 Jan to 9 Jan, the result is 4+5+3+10 = 22

image.png

 

When the date slicer selected 3 Jan to 9 Jan, the result is 4+5 = 9

image.png

 

Many many thanks!

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

Hi @Anonymous ,

 

At first, you need to create a new date dimention as a slicer.

Then refer to the following measure.

Measure =
VAR a =
    CALCULATE ( MIN ( 'Table 2'[Date] ), ALLSELECTED ( 'Table 2'[Date] ) )
RETURN
    CALCULATE ( SUM ( 'Table'[Amount] ), FILTER ( 'Table', 'Table'[Date] < a ) )

Here is the result.

1-2.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

At first, you need to create a new date dimention as a slicer.

Then refer to the following measure.

Measure =
VAR a =
    CALCULATE ( MIN ( 'Table 2'[Date] ), ALLSELECTED ( 'Table 2'[Date] ) )
RETURN
    CALCULATE ( SUM ( 'Table'[Amount] ), FILTER ( 'Table', 'Table'[Date] < a ) )

Here is the result.

1-2.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

@v-eachen-msft 
It's work, many thanks!

amitchandak
Super User
Super User

First, make sure you have date dimension

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

 

After you can try

Value =
var _min = mixx(date,date[date])
Return
calculate(sum(sales[sales Amount]),sales[sales_date]<_min))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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
JustJan
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

I think the measure ican be something like : 

TotalBeforeDate := 
var startdate = min('Dates'[Date])
var result = sumx('Table', if('Table'[Date]<startdate, 'Table'[Amount]))
return result

The startdate refers to the date column you use in the slicer.

 

Hope this helps

Anonymous
Not applicable

@JustJan
Thanks for your help! however it doesn't work!

The slicer will take control only on the selected date bounded, I think it should add function like ALL( ), but I can't do that

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.