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
Anonymous
Not applicable

Getting my cumulative total to stop

Hi all

 

I've spent a day or two exercising my Google-fu but haven't found an iteration that works. I have a cumulative forecast measure (that works) and I've applied a relative date filter that stops the graph showing past the next six months. I want to add the cumulative actuals but I need them to stop at the last date that has an actual, not keep going with a flat line.

 

My cumulative forecast formula (which works) is: 

Cumulative Forecast = CALCULATE([Forecast Logs (+5%)], FILTER(ALLSELECTED(DateTable), DateTable[Date] <= MAX(DateTable[Date])))
 
My cumulative actual forecast (which technically works, just keeps going that is all) is:
Cumulative Actual = CALCULATE([Total Tonnes], FILTER(ALLSELECTED(DateTable), DateTable[Date] <= MAX(DateTable[Date])))
 
My data model is simple; one table of data, and one date table. I have included a Week Ending date which is what I want to graph this on.
 
Including some sample data and the screenshot of what I have so far. Would really appreciate any guidance or shared wisdom, please!
 
rachel_g_0-1616977270024.png
DateFromDateToTonnes
20/03/2021 14:1024/03/2021 7:007685.59
15/03/2021 19:1219/03/2021 23:5535367.23
14/03/2021 16:0016/03/2021 8:2011786.17
14/03/2021 9:2417/03/2021 20:4024553.34
12/03/2021 15:1214/03/2021 9:309304.24
9/03/2021 7:5013/03/2021 0:1122591.34
7/03/2021 6:159/03/2021 6:4017996.99
6/03/2021 11:559/03/2021 7:108930.37
3/03/2021 9:364/03/2021 16:408407.17
1/03/2021 22:004/03/2021 13:1514951.53
27/02/2021 5:183/03/2021 10:1524457.42
27/02/2021 0:0028/02/2021 0:003981.99
26/02/2021 18:5428/02/2021 8:2912017.25
26/02/2021 0:0027/02/2021 0:00200.19
25/02/2021 0:0026/02/2021 0:00780.49
24/02/2021 0:0025/02/2021 0:004250.78
23/02/2021 16:4826/02/2021 15:1528191.76
23/02/2021 0:0024/02/2021 0:004944.33
20/02/2021 10:5522/02/2021 5:247948.28
19/02/2021 0:0021/02/2021 0:006448.36
17/02/2021 12:0020/02/2021 0:2215697.09
17/02/2021 0:0018/02/2021 0:003098.36
16/02/2021 18:3019/02/2021 8:1421074.06
16/02/2021 0:0016/02/2021 0:0088.64
15/02/2021 0:0015/02/2021 0:003905.68
14/02/2021 0:0015/02/2021 0:002987.78
13/02/2021 0:0014/02/2021 0:002708.24
12/02/2021 23:2415/02/2021 20:0519097.89
11/02/2021 1:3713/02/2021 17:4323409.93
11/02/2021 0:0011/02/2021 0:001047.6
1 ACCEPTED SOLUTION

Hi,

Does this measure work

Cumulative Actual = if(isblank([Total Tonnes]),blank(),CALCULATE([Total Tonnes], FILTER(ALLSELECTED(DateTable), DateTable[Date] <= MAX(DateTable[Date]))))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish, my apologies but I can't due to it being commercially sensitive. Was hoping the sample data would be useful. It is a basic data set, only the two tables in the model. 

Hi,

Does this measure work

Cumulative Actual = if(isblank([Total Tonnes]),blank(),CALCULATE([Total Tonnes], FILTER(ALLSELECTED(DateTable), DateTable[Date] <= MAX(DateTable[Date]))))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thats it! Thank you so much. I had tried something similar but obviously didn't have the syntax quite right. Appreciate your time

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AllisonKennedy
Super User
Super User

@Anonymous  What you have is technically correct, but if you want it to stop you can add an IF statement to check if the date is before today:

 

New Measure= IF(DateTable[Date] < TODAY(), BLANK(), [Cumulative Actual])


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

Anonymous
Not applicable

Hi Allison, thank you for that. I may be being a bit of a numpty but I can't create a dax formula with IF and that context in the measure, it won't pick up my date table (I can confirm the relationship is working) so I suspect I need to wrap in in something else. 

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.