Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
* My dax below is giving me correct row subtotal and row grand totals. BUT it is giving me incorrect column grandtotals.
* The grand totals should be the sum of the [Tonnes Actual] component up to current monthyear + [Tonnes Budget] component for future monthyear values from current monthyear value.
* Instead it is giving me only the [Tonnes Budget] values across all dates.
Please help.
Solved! Go to Solution.
I have the solution DAX below just to give closure to this thread. Thank you for your efforts.
I have the solution DAX below just to give closure to this thread. Thank you for your efforts.
HI @arnie ,
Please Try the following DAX code:
_Calc. Budget =
VAR CurrentMonthYear = VALUE(FORMAT(TODAY(), "YYYYMM"))
VAR ColumnDate = MAX('Date'[Date])
VAR ColumnMonthYear =
IF(
ISBLANK(ColumnDate),
BLANK(),
VALUE(FORMAT(ColumnDate, "YYYYMM"))
)
VAR IsGrandTotal = ISINSCOPE('Date'[Month Year]) = FALSE
VAR ActualValue =
IF(
ColumnMonthYear <= CurrentMonthYear,
[Tonnes Actual],
BLANK()
)
VAR BudgetValue =
IF(
ColumnMonthYear > CurrentMonthYear,
[Tonnes Budget],
BLANK()
)
// Correcting the Actual Total to sum up until the current month-year
VAR ActualTotal =
CALCULATE(
[Tonnes Actual],
REMOVEFILTERS('Date'),
'Date'[Month Year] <= CurrentMonthYear
)
// Correcting the Budget Total to sum from future months beyond the current month-year
VAR BudgetTotal =
CALCULATE(
[Tonnes Budget],
REMOVEFILTERS('Date'),
'Date'[Month Year] > CurrentMonthYear
)
RETURN
IF(
IsGrandTotal,
// For Grand Total: Combine the corrected Actual and Budget totals
ActualTotal + BudgetTotal,
// For individual rows, show the Actual or Budget based on the current month-year
ActualValue + BudgetValue
)
Modified version of your DAX measure:
_Calc. Budget =
VAR CurrentMonthYear = VALUE(FORMAT(TODAY(), "YYYYMM"))
VAR ColumnDate = MAX('Date'[Date])
VAR ColumnMonthYear =
IF(
ISBLANK(ColumnDate),
BLANK(),
VALUE(FORMAT(ColumnDate, "YYYYMM"))
)
VAR IsGrandTotal = ISINSCOPE('Date'[Date]) = FALSE
VAR ActualValue =
IF(
ColumnMonthYear <= CurrentMonthYear,
[Tonnes Actual],
BLANK()
)
VAR BudgetValue =
IF(
ColumnMonthYear > CurrentMonthYear,
[Tonnes Budget],
BLANK()
)
VAR ActualTotal =
CALCULATE(
[Tonnes Actual],
FILTER(
ALL('Date'),
VALUE('Date'[Month Year]) <= CurrentMonthYear
)
)
VAR BudgetTotal =
CALCULATE(
[Tonnes Budget],
FILTER(
ALL('Date'),
VALUE('Date'[Month Year]) > CurrentMonthYear
)
)
RETURN
IF(
IsGrandTotal,
ActualTotal + BudgetTotal,
ActualValue + BudgetValue
)
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
* Hi Kedar, please see my screenshots below.
* As you can see, Tonnes + Budget does add up correctly for corresponding date, but the column grand total (3rd table) is the same as the total for budget (2nd table). I need the highlighted totals for Actuals to ADD up with the budget values from Dec 24 onwards to give grand total of 364,007.
* Your solution is not adding up also, but thanks for trying.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
115 | |
77 | |
75 | |
58 | |
57 |
User | Count |
---|---|
128 | |
109 | |
94 | |
70 | |
68 |