Forum Discussion
Compare values from two tables and get count...
- Anonymous3 years ago
Hi ddpl ,
Please try below steps:
1. create a measure with below dax formula
Measure = VAR cur_customer = SELECTEDVALUE ( Sales[Customer_] ) VAR tmp1 = SELECTCOLUMNS ( Stock, "Stock ID", [StockID_], "Product Type", [Product Type_], "Count", [Discount] ) VAR tmp2 = CROSSJOIN ( Sales, tmp1 ) VAR tmp3 = CALCULATETABLE ( VALUES ( Stock[StockID_] ), FILTER ( tmp2, [Customer_] = cur_customer && [Product Type] = [Product Type_] && [Count] > [Discount] ) ) VAR _val = COUNTROWS ( tmp3 ) RETURN IF ( ISBLANK ( _val ), 0, _val )2. add a table visual with field and measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 3 years ago
Anonymous ,
Thanks for the answer, it perfectly work on sample data.
but concern is about cross join, as per my data... cross join created around 9 billion rows and the figure did not show untill I sliced any single customer.
Anyway thanks again for the enlightenment.
Hi ddpl ,
Please try below steps:
1. create a measure with below dax formula
Measure =
VAR cur_customer =
SELECTEDVALUE ( Sales[Customer_] )
VAR tmp1 =
SELECTCOLUMNS (
Stock,
"Stock ID", [StockID_],
"Product Type", [Product Type_],
"Count", [Discount]
)
VAR tmp2 =
CROSSJOIN ( Sales, tmp1 )
VAR tmp3 =
CALCULATETABLE (
VALUES ( Stock[StockID_] ),
FILTER (
tmp2,
[Customer_] = cur_customer
&& [Product Type] = [Product Type_]
&& [Count] > [Discount]
)
)
VAR _val =
COUNTROWS ( tmp3 )
RETURN
IF ( ISBLANK ( _val ), 0, _val )
2. add a table visual with field and measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous ,
Thanks for the answer, it perfectly work on sample data.
but concern is about cross join, as per my data... cross join created around 9 billion rows and the figure did not show untill I sliced any single customer.
Anyway thanks again for the enlightenment.