0
votes

I am new at powerbi dax and I would be very grateful if someone could help with this.

I have a sales table with all the sales, material id, quantities, customer id and delivery date, a customer table with customer ID and contract table with material id, agreed prices, period of time of agreement and customer ID.

As usual, customers place any order but those with a contract for a particular material have a special prices during a period of time. 97% of customers with contract has same customer id contract and sales tables, but there is a 3% of customers with contract that they have other partners (customer ID are not present in contract table) also placing orders under the same contract. I have managed to create a matrix by contract with all the quantity, sales and delivery date for all the materials in the contract. I am having problems to include in the matrix those sales under the contract made by the partners since I am not able to properly modify the selectedvalue of the slicer or of the row in the contract matrix when drillingthough.

I think there should be something like (maybe in a variable):
if selectedvalue(customerID)= "1" then consider customerID = OR(20,33,45,1); if selectedvalue(customer id)= "13" then consider customerID = or(72,42,63); else do not modify selectedvalue(customerID) Apply the original or modified selectedvalue of the previous conditional function to the measure calculating total sales, quantities in a particular period of time.

Thanks a lot.

2
Please share some sample data.AntrikshSharma

2 Answers

0
votes

This can possibly be solved by using a SWITCH function, something like this:

Measure = 
var selVal = SELECTEDVALUE(customerID)

return
SWITCH(
    TRUE(),
    selVal in {"1", "20", "33", "45"}, CALCULATE( EXPRESSION, customerID in {"1", "20", "33", "45"} ),
    selVal in {"13", "42", "63", "72"}, CALCULATE( EXPRESSION, customerID in {"13", "42", "63", "72"} ),
    CALCULATE( EXPRESSION )
)

Depending on what your model looks like there's always a better way to do it. But this should work based on my guess of how your data table looks. Next time please provide a sample data and a model description.

0
votes

Thanks OscarLabr, but your proposal is not working. The returned result is the same I have without considering the partners.

Here you have my model

model

Sample data would be: visual with a table the next columns:"Sold-to" [Sold-to Party] ="1" (customerID which also exists in table 'Unic Contracts'); "Contract Unic Mat" [Material] ="B" (productID), 'Unic Contracts"[sales document] (all the contracts this customer has). I would like to find all the Confirmed Qty for this material B from table "POs" with Delivery dates between dates Valid from to Valid From for all Sold-to Party in table "Unic PO" ="1", "20", "33", "45" (20, 33, 45 do not exist in "Unic Contracts" and they are partners) of a particular 'Unic Contracts'[Sales Document]. I have an activated drill through option giving me all the results I need when selecting a row from the table in the visual.

For customer ID= "2" which has not partners placing orders, my model prefectly works.

I hope the information above helps you you understand a little bit better my question.