Forum Discussion

Excellove15's avatar
Excellove15
Iron Contributor
Sep 10, 2023

Table visual values does not add up to its correct total

Hi,   I have a table visual whose Forecast column values are correct for their months. But its Total  doesn't add up when we sum all values. The visual is shown below whose forecast total 280,000 ...
  • SergeiBaklan's avatar
    Sep 10, 2023

    Excellove15 

    Measure in totals doesn't return sum of monthly sums, it calculates result for entire period (i.e. year) ignoring row context for each month. I didn't dig details, at least

    DATEDIFF (EOMONTH ( MAX ( Calendar_[Date] ), -1 ), EOMONTH ( MAX ( Calendar_[Date] ), 0 ), DAY )

    for entire year returns 31 (days in the latest month), not dates of the year.

     

    If you need sum of monthly sums in total, not calculation on entire year, you may calculate forecast like

    Forecast = IF (
        HASONEVALUE ( 'Calendar_'[Month] ),
        CALCULATE ( SUMX ( VALUES ( Points[DBName-Point_Id] ), [Pre_Forecast] ) ),
        SUMX (
            VALUES ( 'Calendar_'[Month] ),
            CALCULATE ( SUMX ( VALUES ( Points[DBName-Point_Id] ), [Pre_Forecast] ) )
        )
    )

    don't  use VAR in above, most probably will be incorrect result.

    To use for Total calculation on entire period or sum results for internal periods depends on your business logic. Since you averaging inside, results could be different assuming DAX code is correct.

     

    In general if you work with Power BI it's much better to discuss that on Microsoft Power BI Community - Microsoft Fabric Community Here are much more people who are working with data modelling and in average they have more experience.  Plus Power Pivot works bit differently compare to data modelling in Power BI. And at least you could share .pbix files directly.

Resources