简体   繁体   中英

Sum with filter based on string Power BI

I have this Table .

I want to create a measure that will only work with the Products containing "HDD" in their name (first, second and fifth product in that case).

It's working with that formula : HDDProduct= CALCULATE(COUNT([Product]),FILTER(ALL([Product]),SEARCH("HDD",[Product],1,0)))

It only count the number of product with HDD in their name. But if I want a sum of the prices of those products for example, it won't work. I can only use COUNT.

Any idea ?

for sum you have to create another measure, below are my resolution to your question

for count HDDProduct_count = CALCULATE(COUNT([Product]),FILTER(Product_table,SEARCH("HDD",[Product],1,0)))

for price sum HDDProduct_Price_sum = CALCULATE(SUM(Product_table[Price]),FILTER(Product_table,SEARCH("HDD",[Product],1,0)))

note: please check the data type of price column to integer data type

我在Power Bi中的结果的屏幕截图

download pbix file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM