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
Syndicate_Admin
Administrator
Administrator

Create cumulative curve that ends when there is no more data

I want to do a study on the shelf life of products. To do this, I've created a measure that accumulates sales over the years since launch.

The formula is this:

CUMULATIVE Sale = CALCULATE(

SUM('Sales'[Sales Amount]),

FILTER(

ALL('Years Since Launch'),

'Years Since Release'[Years Since Release] <= MAX('Years Since Release'[Years Since Release]))))

And the image it creates for me is as follows:

UCR522_0-1700563863356.png

What's the matter? If we look at the example of 2016, the curve is flat from year 8 onwards because from 2016 to 2023 7 years have elapsed and there is data from year 8 onwards.

What should the DAX formula for cumulative selling look like so that when the value of the x-axis is greater than the difference between today and the launch year, the calculation is interrupted?

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

Hi @Syndicate_Admin ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.

vtangjiemsft_0-1700709569154.pngvtangjiemsft_1-1700709580216.png

(2) We can create a measure. 

CUMULATIVE Sale = 

var _a=CALCULATE(
SUM('Sales'[Sales Amount]),
FILTER(
ALL('Sales'),
'Sales'[Year]=MAX('Sales'[Year]) && 'Sales'[Years Since Release] <= MAX('Years Since Launch'[Years Since Release])))
var _b=YEAR(TODAY())-SELECTEDVALUE('Sales'[Year])
return IF(SELECTEDVALUE('Years Since Launch'[Years Since Release])>=_b+1,BLANK(),_a)

(3) Then the result is as follows.

vtangjiemsft_2-1700709652390.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.

vtangjiemsft_0-1700709569154.pngvtangjiemsft_1-1700709580216.png

(2) We can create a measure. 

CUMULATIVE Sale = 

var _a=CALCULATE(
SUM('Sales'[Sales Amount]),
FILTER(
ALL('Sales'),
'Sales'[Year]=MAX('Sales'[Year]) && 'Sales'[Years Since Release] <= MAX('Years Since Launch'[Years Since Release])))
var _b=YEAR(TODAY())-SELECTEDVALUE('Sales'[Year])
return IF(SELECTEDVALUE('Years Since Launch'[Years Since Release])>=_b+1,BLANK(),_a)

(3) Then the result is as follows.

vtangjiemsft_2-1700709652390.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

lbendlin
Super User
Super User

Have your measures return BLANK() where there is no more data.

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.