Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Hi, Can you please help me below SQL statement in power BI:

Hi, Can you please help me below SQL statement in power BI: Case(i): , Top20PartNumber_cte As ( Select Top 20 eqpartnumber, Sum(Qty) As Tot_Qty, Sum(Cost) As Tot_Cost From RawData_cte Group By...
  • v-alq-msft's avatar
    5 years ago

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table1:

     

    Table2:

     

    You may create a calculated column or a measure as below.

    Calculated column:

    Flag Column = 
    TRIM([eqpartnumber]) in 
    SELECTCOLUMNS(
        ADDCOLUMNS(
            Table2,
            "Result",
            TRIM(Table2[eqpartnumber])
        ),
        "Res",
        [Result]
    )

     

    Measure:

    Flag Measure = 
    TRIM(SELECTEDVALUE(Table1[eqpartnumber])) in 
    SELECTCOLUMNS(
        ADDCOLUMNS(
            Table2,
            "Result",
            TRIM(Table2[eqpartnumber])
        ),
        "Res",
        [Result]
    )

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.