Forum Discussion

mb0307's avatar
mb0307
Icon for Responsive Resident rankResponsive Resident
4 years ago
Solved

SUMX from two tables

Hi all,

 

I have two tables 

  1. Forecast
  2. Sales

A simple measure to calculate difference between two:

Diff = ABS( [Forecast] - [Sales] )

 

Then I want sum of Diff by Month and Product, so written this measure:

Error Forecasting = 
    SUMX(
        VALUES( ProductTable[ProductID] ),
        [Diff]

 

This works fine if I am using columns from Product table as row header. 

 

But if I want to use Month from Date table as subgroup/column then total doesn't add up correctly:

 

 

Total 11,585,881 is correct if I only use Product Group and number for each Month is correct.  But total should be 16,915,804

 

Any solution amending the Error Forecasting measure please? you help is much appreciated.

Thanks 

  • Hi,

    Try this measure

    Diff v3 = 
        SUMX(
            generate(VALUES('Product'[Product ID] ),values('Date'[MonthNameShort])),
            [Diff]
        )

6 Replies

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Hi,

        Try this measure

        Diff v3 = 
            SUMX(
                generate(VALUES('Product'[Product ID] ),values('Date'[MonthNameShort])),
                [Diff]
            )