Hi,
I'm struggling to do something in DAX that seems should be easy. I have a ProductFact table where I want to select
products which are in store 73 and also in the other estores.
I use this query which works fine.
EVALUATE
FILTER(
KM_ProductFact,
CONTAINS(FILTER(KM_ProductFact, KM_ProductFact[StoreID]=73), KM_ProductFact[ProductID], KM_ProductFact[ProductID])
)
result is
Now I want to compare the prices for products with other estores and find out which are cheaper than the primary estore(73).
I created this query
DEFINE
MEASURE KM_ProductFact[MyMeasure] = CALCULATE( AVERAGE( KM_ProductFact[Price] ), KM_ProductFact[StoreID] = 75)
EVALUATE
ADDCOLUMNS(
FILTER(
KM_ProductFact,
CONTAINS(FILTER(KM_ProductFact, KM_ProductFact[StoreID]=75), KM_ProductFact[ProductID], KM_ProductFact[ProductID])
),
"Nom. dif.", KM_ProductFact[MyMeasure] - KM_ProductFact[Price]
)
but a problem is that the new column "Nom. dif." has value only for store 75. Is not sliced by productID for every row and therefore there is minus result 0 - KM_ProductFact[Price]
result2
Correct result should be
"Nom. dif."
1 (203 - 202)
3 (203-200)
0 (203 - 203 )
Thank you for your help, because I don't have any idea how to continue.
Michal
I'm struggling to do something in DAX that seems should be easy. I have a ProductFact table where I want to select
products which are in store 73 and also in the other estores.
I use this query which works fine.
EVALUATE
FILTER(
KM_ProductFact,
CONTAINS(FILTER(KM_ProductFact, KM_ProductFact[StoreID]=73), KM_ProductFact[ProductID], KM_ProductFact[ProductID])
)
result is
Now I want to compare the prices for products with other estores and find out which are cheaper than the primary estore(73).
I created this query
DEFINE
MEASURE KM_ProductFact[MyMeasure] = CALCULATE( AVERAGE( KM_ProductFact[Price] ), KM_ProductFact[StoreID] = 75)
EVALUATE
ADDCOLUMNS(
FILTER(
KM_ProductFact,
CONTAINS(FILTER(KM_ProductFact, KM_ProductFact[StoreID]=75), KM_ProductFact[ProductID], KM_ProductFact[ProductID])
),
"Nom. dif.", KM_ProductFact[MyMeasure] - KM_ProductFact[Price]
)
but a problem is that the new column "Nom. dif." has value only for store 75. Is not sliced by productID for every row and therefore there is minus result 0 - KM_ProductFact[Price]
result2
Correct result should be
"Nom. dif."
1 (203 - 202)
3 (203-200)
0 (203 - 203 )
Thank you for your help, because I don't have any idea how to continue.
Michal