In Power BI, I'm encountering discrepancies in my measure values between row-level and aggregated views of my data. When I don't summarize the balance column in my table, each row displays the correct value for my measures. However, when I summarize the balance column to show totals, the measure values (Balance Change and Paid Off) for the total are not correct. How can I ensure that my measures behave consistently, whether the balance column is summarized or not.
Here are both of my measures that I am using as columns in my table.
PaidOff =
VAR PreviousMonthBalance =
CALCULATE(
SUMX(FILTER(Query1,Query1[act_end_bal] > 0),
Query1[act_end_bal]),
PREVIOUSMONTH(Query1[analysis_date]))
VAR CurrentMonthBalance =
CALCULATE(
SUMX(FILTER(Query1,Query1[act_end_bal] > 0),Query1[act_end_bal]),
Query1[analysis_date] = MAX(Query1[analysis_date]))
RETURN
IF( CurrentMonthBalance = 0, PreviousMonthBalance, 0)
and
Balance Change =
VAR CurrentMonthBalance = SUM(Query1[act_end_bal])
VAR PreviousMonthBalance = CALCULATE(SUM(Query1[act_end_bal]),PREVIOUSMONTH(Query1[analysis_date]))
RETURN
IF(PreviousMonthBalance > 0 && CurrentMonthBalance > 0, CurrentMonthBalance - PreviousMonthBalance, 0)