The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I am struggling to calculate cumulative totals. Hopefully someone can help!
I have a measure that i have created to calculate the total value of sales YTD (fromt Oct 2019 to today) - this is the measure i am basing my cumulative totals off if possible? (FYI this measure works for calculating YTD sales value)
Hi @JamesGordon
i think you can use much more simple version
Cumulative test = CALCULATE(SUM('Sheet (2)'[Total Sell]), 'Sheet (2)'[Status] = "S", 'Sheet (2)'[Total Cost]>100 , 'Sheet (2)'[Inv date]<=MAX('Sheet (2)'[Inv date]) )
Thanks Az38,
I have tried your suggestion but get the following error?
Cumulative test =
var __maxDate = MAX ( 'Sheet (2)'[Inv date] )
var __minCost = 100
var __status = "S"
return
CALCULATE (
SUM ( 'Sheet (2)'[Total Sell] ),
keepfilters('Sheet (2)'[Status] = __status),
keepfilters('Sheet (2)'[Total Cost] > __minCost),
'Sheet (2)'[Inv date] <= __maxDate
)
Copy this as is. No changes.
Best
D
Hi D,
Thank you for your DAX - that is working with no errors.
However my graph is still presenting the data on a Monthly basis and not accumulating? I am using the Inv Date as the X-axis and your DAX as the measure - or am i missing a step?
Power Bi appears to have automatically recognised my "Inv Dates" as dates - screenshot below
However if i use the "Inv Date" as the X-axis with your DAX as my measure it still produces the graph as per my previous post and doesnt accumulate the values?
Please try this:
Cumulative test =
var __maxDate = MAX ( 'Sheet (2)'[Inv date].[Date] )
var __minCost = 100
var __status = "S"
return
CALCULATE (
SUM ( 'Sheet (2)'[Total Sell] ),
KEEPFILTERS('Sheet (2)'[Status] = __status),
KEEPFILTERS('Sheet (2)'[Total Cost] > __minCost),
'Sheet (2)'[Inv date].[Date] <= __maxDate
)
Warning: DO NOT EVER RELY ON THE AUTOMATIC DATES FEATURE IN POWER BI. Unless you want to suffer...
Best
D
I would say i have text that looks like dates.
By your comment i am guessing i need to create a date data type? If so how would you recommend the best way forward?
Hi @JamesGordon
you did not use my suggestion, i see a lot of filters in your statement
Hi Az38,
Apolagies, I have now removed the filters and directly copied and pasted your suggestion but still getting the same error in regards the MAX function
"A function 'MAX' has been used in a True/False expression that is used as a table filter expression. This is not allowed."
Is there another function I should be using instead?
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
12 | |
8 | |
8 |