Forum Discussion

OscarRissveds's avatar
OscarRissveds
Regular Visitor
3 years ago
Solved

ABS Calculation from two tables

I have two tables, one with order data and one with sales data.

Both are connected to a masterdata table for product information and a date table for joint dates. 

 

In my report i want to visualize product, order, sales and a calculated absolute (ABS) difference between order and sales.

This is working fine on product level but sums up an incorrect total.

 

Example:

 

Order_Table:

ProductDateOrder_Value
Product 12022-08-011 250 000
Product 22022-08-01250 000
Product 12022-09-01750 000
Product 22022-09-01

200 000

 

Sales_Table:

ProductDateSales_Value
Product 12022-08-011 000 000
Product 22022-08-01250 000
Product 12022-09-01800 000
Product 22022-09-01300 000

 

Below is the result from my current calculation and as you can see I get an ABS Error of 100 000 but I want it to be 400 000.

I have tried som different SUMX formulas but I havent yet succed to get them work

 

Report:

ProductMonthOrderSalesErrorABS Error
Product 12022-081 250 0001 000 000250 000250 000
Product 22022-08250 000250 00000
Product 12022-09750 000800 000-50 00050 000
Product 22022-09200 000300 000-100 000100 000
Total 2 450 0002 200 000100 000100 000 (400 000)

 

How should I do to get the ABS Error total that I want? Do i need to join tables?

  • OscarRissveds 

    Ah, I see. 

    Try this instead: 

     

    SUMX ( 
        CROSSJOIN ( 
            VALUES ( 'Product Master Table'[Product] ),
            VALUES ( 'Date Table'[Month] )
        ),
        CALCULATE ( ABS(SUM(Order_Table[Order_Value])-SUM(Sales_Table[Sales_Value]))))

     

     

4 Replies

  • m_alireza's avatar
    m_alireza
    Icon for Solution Specialist rankSolution Specialist

    OscarRissveds 

    Ah, I see. 

    Try this instead: 

     

    SUMX ( 
        CROSSJOIN ( 
            VALUES ( 'Product Master Table'[Product] ),
            VALUES ( 'Date Table'[Month] )
        ),
        CALCULATE ( ABS(SUM(Order_Table[Order_Value])-SUM(Sales_Table[Sales_Value]))))

     

     

  • m_alireza's avatar
    m_alireza
    Icon for Solution Specialist rankSolution Specialist

    Hi OscarRissveds ,

    Can you try this measure: 

    ABS Error = SUMX(VALUES('Master Data Table'[Product]), ABS(SUM(Order_Table[Order_Value])-SUM(Sales_Table[Sales_Value])))

     

  • Hi m_alireza

     

    Thank you for your answer!

     

    Do you have any solutions how I can filter the formula above on dates (months)?

    When I try it its sums every product on a total date horizon even if I filter the report on specific months.

     

    /Oscar