Forum Discussion
Filtering information in order to perform a calculation
Hi
I have a number of tables that are giving me data that I need to perform calculations on and then combine and give each customer a 'score'.
I have done a number of calculations and I can use the slicer to give me a total score per customer per product but I am struggling to filter a score by product in Dax to enable a percentage calculation. I need to factor in the product as the total possible instances are different by product.
For example:
If the customer has had product 1 then their 'total score' should be divided by 100 to give the percent.
If the customer has had product 2 then their 'total score' should be divided by 200 to give the percent.
How can I reference this and make my calculations work?
Thanks
Hi Catherine_Anne ,
Try something like this:
Measure = VAR Customer_ = MAX ( 'Table'[Customer] ) VAR t = CALCULATETABLE ( VALUES ( 'Table'[Product] ), 'Table'[Customer] = Customer_ ) RETURN SWITCH ( TRUE (), "Product 1" IN t, [Total Score] / 100, "Product 2" IN t, [Total Score] / 200 )Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- Icey
Community Support
Hi Catherine_Anne ,
Try something like this:
Measure = VAR Customer_ = MAX ( 'Table'[Customer] ) VAR t = CALCULATETABLE ( VALUES ( 'Table'[Product] ), 'Table'[Customer] = Customer_ ) RETURN SWITCH ( TRUE (), "Product 1" IN t, [Total Score] / 100, "Product 2" IN t, [Total Score] / 200 )Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- edhans
Community Champion
If you use COUNTROWS(VALUES(Table[Products)) it will return the number of distinct products for that calculation. You may need to use that in a FILTER() by customer depending on how your model is filtering that measure. Then multiply that by 100.
But we'd need to see data to really assist further.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum