Forum Discussion
What if parameter
- 6 years ago
ScaR what do you think of this solution?
Total Profit = VAR __Product = SELECTEDVALUE('Table'[Product],BLANK()) VAR __NewQty = [QtyValue] VAR __Table = ADDCOLUMNS( ADDCOLUMNS( ALL('Table'), "__NewQty",IF('Table'[Product] = __Product,__NewQty,[Qty]) ), "__Total Profit",'Table'[Profit] * [__NewQty] ) RETURN SUMX(__Table,[__Total Profit])Attached PBIX
Thank you for your response Greg.
Here is the scenario. I have a table like this,
| Product | Cost | Price | Profit | Qty |
| A | 100 | 115 | 15 | 4 |
| B | 50 | 60 | 10 | 5 |
| C | 20 | 25 | 5 | 2 |
And a measure for total profit, which I'm displaying as a card. Then, I have slicer for product and a What if parameter for qty change.
Now, I want to have the Total Profit card to show the total profit of all the products - $120 (per above table), even if, I select the product B on the slicer. Also, if I add qty for product B to 3 (total - 8), I want the total profit to display $150.
I am really not able to connect with number $120 and $150. basis of adding 3.
- ScaR6 years agoRegular Visitor
Here is the break up.
Total Profit(Measure) = Profit per product * Qty
$120 = (15*4) + (10*5) + (5*2)
So, in the what if parameter if I add 3 qty to Product B (meaning if we are able to sell 3 more product B), then total qty for product B is 8.
Total Profit: $150 = (15*4) + (10*5) + (5*2) + (10*3) {this 10* 3 comes from the what if).
- Greg_Deckler6 years agoCommunity Champion
ScaR what do you think of this solution?
Total Profit = VAR __Product = SELECTEDVALUE('Table'[Product],BLANK()) VAR __NewQty = [QtyValue] VAR __Table = ADDCOLUMNS( ADDCOLUMNS( ALL('Table'), "__NewQty",IF('Table'[Product] = __Product,__NewQty,[Qty]) ), "__Total Profit",'Table'[Profit] * [__NewQty] ) RETURN SUMX(__Table,[__Total Profit])Attached PBIX