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
aulla
Frequent Visitor

Running Totals Over Extended Period of Time

Hi

 

I have a table just like this:

 

Created

Product

Delincuency

Value

1/1/2024

A

1/5/2024

1

1/2/2024

B

1/8/2024

1

1/3/2024

C

1/12/2024

1

1/4/2024

D

1/15/2024

0

2/1/2024

E

2/5/2024

0

2/1/2024

F

2/12/2024

0

2/1/2024

G

2/17/2024

1

2/1/2024

H

2/18/2024

1

2/1/2024

I

2/19/2024

1

 

This table has a date of creation, a productname, a date of when they fall on delincuency and wheter they have fallen on delincency or not. I would like to create a running sum measure in dax that when filtering by date of creation through a date table (for example, January) would allow me to calculate the sum of value between al calendar dates withing default date, that would yield a result looking like this:

 

Date

Value

Running Sum

1/1/2024

0

0

1/2/2024

0

0

1/3/2024

0

0

1/4/2024

0

0

1/5/2024

1

1

1/6/2024

0

1

1/7/2024

0

1

1/8/2024

1

2

1/9/2024

 0

2

1/10/2024

 0

2

1/11/2024

 1

3

1/12/2024

 0

3

1/13/2024

 0

3

1/14/2024

 0

3

...TODAY

 1

4

 

This way I would have a running total of the clients that have defaulted over the actual period since their deal was created and not just a running sum over the dates they default.

 

I have already tried differnt methods, but i have only beend able to make it work 

 

 

 

 

Value Over Time = 
VAR MaxDate = MAX(Delincuency)
RETURN
CALCULATE(
    SUM(Value), 
    FILTER(ALLSELECTED(Date Table), 
    Date Table<=MaxDate))
)

 

 

 

 

This works under normal circumstances, but doesnt do as i need, which is to have the poper range between when i selecte a creation date and today and then the running total over that.

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

Hi @aulla 

 

Thank you very much PhilipTreacy for your prompt reply.

 

Is your problem solved? If not, let me add something to PhilipTreacy's answer.

 

You need to have a table to create the slicer.

 

 

DateSlicer = CALENDAR("1/1/2024", "12/31/2024")

 

 

Create a slicer.

 

vnuocmsft_1-1727079203727.png

vnuocmsft_0-1727079186134.png

 

Create a measure.

 

 

RT = 
CALCULATE(
	SUM('DataTable'[Value]),
	FILTER(
		ALL('DateTable'),
		ISONORAFTER('DateTable'[Date], MAX('DateTable'[Date]), DESC)
        &&
        MONTH('DateTable'[Date]) >= SELECTEDVALUE('DateSlicer'[Date].[MonthNo])
	)
)

 

 

You also need to create a measure to filter the data in the table.

 

 

Measure = 
IF(
    MONTH(SELECTEDVALUE('DateTable'[Date])) >= SELECTEDVALUE('DateSlicer'[Date].[MonthNo]),
    1,
    0
)

 

 

vnuocmsft_2-1727079576318.png

 

Here is the result.

 

vnuocmsft_3-1727079610948.png

 

Regards,

Nono Chen

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

5 REPLIES 5
v-nuoc-msft
Community Support
Community Support

Hi @aulla 

 

Thank you very much PhilipTreacy for your prompt reply.

 

Is your problem solved? If not, let me add something to PhilipTreacy's answer.

 

You need to have a table to create the slicer.

 

 

DateSlicer = CALENDAR("1/1/2024", "12/31/2024")

 

 

Create a slicer.

 

vnuocmsft_1-1727079203727.png

vnuocmsft_0-1727079186134.png

 

Create a measure.

 

 

RT = 
CALCULATE(
	SUM('DataTable'[Value]),
	FILTER(
		ALL('DateTable'),
		ISONORAFTER('DateTable'[Date], MAX('DateTable'[Date]), DESC)
        &&
        MONTH('DateTable'[Date]) >= SELECTEDVALUE('DateSlicer'[Date].[MonthNo])
	)
)

 

 

You also need to create a measure to filter the data in the table.

 

 

Measure = 
IF(
    MONTH(SELECTEDVALUE('DateTable'[Date])) >= SELECTEDVALUE('DateSlicer'[Date].[MonthNo]),
    1,
    0
)

 

 

vnuocmsft_2-1727079576318.png

 

Here is the result.

 

vnuocmsft_3-1727079610948.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Wonderfull, pretty much thats what i needed. Just want to add an extra filter to the measure so it only works with the selected month: 

 

RT = 
CALCULATE(
	SUM('DataTable'[Value]),
	FILTER(
		ALLSELECTED('DateTable'),
		ISONORAFTER('DateTable'[Date], MAX('DateTable'[Date]), DESC)
        &&
        MONTH('DateTable'[Date]) >= SELECTEDVALUE('DateSlicer'[Date].[MonthNo])
    )
    ,MONTH('DataTable'[Created])<= SELECTEDVALUE('DateSlicer'[Date].[MonthNo])
	
)
aulla
Frequent Visitor

Hi @PhilipTreacy 

 

Ver interesting function that i didnt know about. Is there any way to make it work by filtering by creation month date?  The idea is to see how the products have evolved over time since their date of creation. For example, if i filter by february or january it should look something like this:

 

aulla_0-1726776111536.png

 

PhilipTreacy
Super User
Super User

Hi @aulla 

 

Download example PBIX file

 

I've created a Datetable and created a relationship between it and the Delinquency column.

 

Try this

 

 

RT = 
CALCULATE(
	SUM('DataTable'[Value]),
	FILTER(
		ALLSELECTED('DateTable'[Date]),
		ISONORAFTER('DateTable'[Date], MAX('DateTable'[Date]), DESC)
	)
)

 

 

PhilipTreacy_0-1726703919565.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!


Hi Philip,

 

Quite an interesting function i dindt know about. How can i make it work with a date of creation filter?

 

 

For example if i filter by products created in february i sohuld look like this:

 

DateValueRunnig Total
2/1/202400
2/2/202400
2/3/202400
2/4/202400
2/5/202400
2/6/202400
2/7/202400
2/8/202400
2/9/202400
2/10/202400
2/11/202400
2/12/202411
2/13/202401
2/14/202401
2/15/202401
2/16/202401
2/17/202412
2/18/202413
2/19/202414
…Today04

 

or if i filter by those created in january:

 

DateValueRunnig Total
1/1/202400
1/2/202400
1/3/202400
1/4/202400
1/5/202411
1/6/202401
1/7/202401
1/8/202412
1/9/202402
1/10/202402
1/11/202402
1/12/202413
1/13/202403
1/14/202403
1/15/202414
1/16/202404
1/17/202404
1/18/202404
1/19/202404
…Today04

 

Those tables look quite bad. Leaving a picture for better understanding:

 

aulla_0-1726761561903.png

 

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.