Forum Discussion

ddpl's avatar
ddpl
Icon for Solution Sage rankSolution Sage
3 years ago
Solved

Compare values from two tables and get count...

Hello,   I have two tables, First one is... Sales, SaleID_ Product Type_ Customer_ Discount 1 A Ram 15 2 B Ram 16 3 B Krishna 17 4 C Krishna 18 5 D Krishna 19 ...
  • Anonymous's avatar
    Anonymous
    3 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.

  • ddpl's avatar
    ddpl
    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.