Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Dax issue
below is my dax
Solved! Go to Solution.
Please refer to the screenshot
Hi @vjnvinod ,
You can follow the below steps:
Create Separate Measures for Actuals and Forecasts:
Create the Cumulative Measure:
Combine the Cumulative Actuals and Forecasts:
Adjust the Total Calculation:
This approach should ensure that your totals add up correctly, reflecting both the cumulative actuals and forecast values as expected.
If this solutions worked, please accept the solution so others can get it as well.
Regards,
Suresh Patra
https://www.linkedin.com/in/sureshpatra
Hi @vjnvinod
Your calculation needs to be evaluated for each month row and then summed up.
Cumulative Actual + Forecast =
SUMX (
VALUES ( GroupOPEXCAPEX[month] ),
IF (
CALCULATE (
SUM ( 'GroupOPEXCAPEX'[Value] ),
'GroupOPEXCAPEX'[Actual/Budget] = "Actuals"
) > 0,
-- Use Cumulative Actuals for months with Actuals
CALCULATE (
SUM ( 'GroupOPEXCAPEX'[Value] ),
FILTER (
ALLSELECTED ( 'GroupOPEXCAPEX' ),
'GroupOPEXCAPEX'[DateColumn] <= MAX ( 'GroupOPEXCAPEX'[DateColumn] )
&& 'GroupOPEXCAPEX'[Actual/Budget] = "Actuals"
)
),
-- Use Forecast for months without Actuals
CALCULATE (
SUM ( 'GroupOPEXCAPEX'[Value] ),
'GroupOPEXCAPEX'[Actual/Budget] = "Forecast"
)
)
)
Provided code doesn't work either, see below, instead of cumulative actuals it shows actuals now
As i mentioend in my previous message, since you do not have a Calendar table, you are facing problems.
thanks Ashish, is there a workaround without Calendar table, or is it mandatory to create a calendar table, as the dataset is very small.
Always preferred.
There's a reason why using a separate dates/calendar table is a best practice. It simplifies time intelligence calculations. While time intelligence can be done sans this table, you will start seeing unexpected result once you add columns not included in your filter context argument. You can't just use ALL(facttable) as this will return the same value regardless of any filter coming from that table. Anyway, try this:
Cumulative Actual + Forecast2 =
IF (
NOT ( HASONEVALUE ( GroupOPEXCAPEX[month] ) ),
SUMX (
VALUES ( GroupOPEXCAPEX[month] ),
IF (
[Actuals] > 0,
[Actuals],
-- Use Forecast for months without Actuals
[Forecast]
)
),
[Cumulative Actual + Forecast]
)
Use the original formula that you used for Cumulative Actual + Forecast. The logic is , at the total level, to add the total actuals + forecast (if actuals is 0, 291M + 31M ) but at the month level to return Cumulative Actual + Forecast measure
Please refer to the screenshot
@danextian any way to show the cumulative of Forecast as well? also i am trying to plot this in line graph and not able to find a way to distinguish the Forecast and actuals
any suggestions?
You will need to write a separate measure for that which is very similar to below
CALCULATE (
SUM ( 'GroupOPEXCAPEX'[Value] ),
FILTER (
ALLSELECTED ( 'GroupOPEXCAPEX' ),
'GroupOPEXCAPEX'[DateColumn] <= MAX ( 'GroupOPEXCAPEX'[DateColumn] )
&& 'GroupOPEXCAPEX'[Actual/Budget] = "Forecast"
)
)
The forecast line will continue until December. If you want it to be until when there is a value for actuals, you can include a condition:
IF (
[Actuals] <> 0,
CALCULATE (
SUM ( 'GroupOPEXCAPEX'[Value] ),
FILTER (
ALLSELECTED ( 'GroupOPEXCAPEX' ),
'GroupOPEXCAPEX'[DateColumn] <= MAX ( 'GroupOPEXCAPEX'[DateColumn] )
&& 'GroupOPEXCAPEX'[Actual/Budget] = "Forecast"
)
)
)
a
i want to plot acutal and forecast in one line, actuals should be plane and forecast like a dotted line
problem i am facing is the last dax you shared is not cumulating the remaining months forecast with the cumulated actuls, so it has to be 295+15 and so on so forth til december
some tweaking needs in that measure, so to be able to cumulate the forecast number as well with actuals
You will still need two separate measures: Cumulative Actual and Forecast (not cumulative), or you won't be able to distinguish them. That aside, there will be a gap between Oct and Nov in your line chart as the two measures will not be connected. The workaround is to include either the forecast for Nov in the Cumulative Actual measure or include Oct in the Remaining Forecast measure.
Forecast with prev month's cumulative value =
IF (
SELECTEDVALUE ( GroupOPEXCAPEX[Month] ) --last month with actuals
= CALCULATATE (
LASTNONBLANK ( GroupOPEXCAPEX[Month], [Actuals] ),
ALL ( GroupOPEXCAPEX[Month] )
),
[Cumulative],
[Remaining Forecast]
)
,
There is an extra opening parenthesis in your measure:
Hi,
The very first blunder is that you do not have a Calendar Table. Anyways, this measure pattern should work
Measure = SUMX(Calendar[Month name],[Cumulative Actual + Forecast])
In the visual, the Year and Month name fields should be dragged from the Calendar Table. In your existing meaure as well, changes will have to be made but with the information which you have shared, this is the max i can help you.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.