Forum Discussion

alihijazi's avatar
alihijazi
Icon for Helper I rankHelper I
10 years ago
Solved

help in measure

Hello I'm new to Power BI

I want to create a measure that calculates the sum(qty*price) where product_type = 'X' or Product_type='Y'

Please advise

  • Hello,

     

    Try this measure
    SUMX(Table, IF(OR(Table[Product_Type]="X", Table[Product_Type]="Y"), Table[Qty]*Table[Price], ""))

     

    But I believe there's an easier way if someone else can help.

2 Replies

  • Hello,

     

    Try this measure
    SUMX(Table, IF(OR(Table[Product_Type]="X", Table[Product_Type]="Y"), Table[Qty]*Table[Price], ""))

     

    But I believe there's an easier way if someone else can help.

  • v-sihou-msft's avatar
    v-sihou-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi alihijazi,

     

    You can apply the filters within SUMX() function. The expression can be like:

     

    =SUMX(FILTER(table,OR(table[product_type]="X",table[product_type]="Y")),table[qty]*table[price])

     

    Reference:SUMX Function (DAX)

     

    Regards,