Forum Discussion

Power-Central's avatar
Power-Central
Frequent Visitor
2 years ago
Solved

DAX Refund Measure uses other Realationship in Modell with Wrong results

Hello, i am in trouble with an Dax-Calculation. The Issue is, that I want to use aqn different Relationship in the Data Modell to get the result of the Total refund. In my Modell there are the Tab...
  • shafiz_p's avatar
    shafiz_p
    2 years ago

    Yes, I got your file. You are getting ambiguous relationship because of multiple filter propagation paths between model tables, and you would not be able to create any active relationship. To solve this you can use user relationship function for inactive relationship. Or you can use TreatAS function, in this way you don't need to create any relationship between them.

    You can create a seperate table with only channel and orderId column and create one to many relationship. Also delete channel from order table because it is meaning less. see the image below:

     

    If you don't want to create table like sheet1, then I would suggest use Treat As function in your "Refund Wrong Date" measure like below:

    Refund wrong Date =
        CALCULATE(
            SUM(Refund[GrandTotal]),
            TREATAS(VALUES('Order'[OrderId]), Refund[OrderId])
        )

    Use channel from order in rows and value section use measue Order and Refund wrong date.

    Now if you wants to know, Channel wise total sales and refund, you will get your desired result.  See image below:

    When there is no active or inactive relationship, only use TreatAs function:

     

    I have filtered out blank.
     

    When there is active relationship, both giving the same result:

    So choice is yours. Now about the date from date table. You have only year 2024 in date table. Refunded value will increase if you go date wise and will decrease if you go with channel.

     

    Because channel related to refund table using OrderID and date table related to refund table using date. 2 different type relationship. 


    If you manually filter refund table for only 1/3/2024 you will get 121 order and in order table you will get 56 order and I have check there is no match id between 2 tables. see image below:

     

     

    You are not getting any refund for 1/3/2024 using orderid from ordertable. Meaning no matching orderid between order table and refund table at that date 1/3/2024.

    so completely 2 different type of relationship will produce 2 different result. 

    Hope this helps!!
    If this solved your query, please accept it as a solution!!