Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Row-wise evaluation of formula before summarization

Hi,

 

I would like to calculate a measure based on column data and What-If-Parameter input. In my case, I have a What-If-Parameter "Financial Cap" and another one "Base Value". In addition, I have a table with two columns, ID and Relevant Compensation

 

In Excel I would do something like this but I am not able to replicate this in Power BI:

  1. Add a new column
  2. Add the formula IF((Relevant Compensation * 0.5 + Base Value)>Financial Cap,Financial Cap,(Relevant Compensation * 0.5 + Base Value))
  3. Sum up the new column

 

As far as I know, calculated columns cannot work with What-If-Parameters. However, a measure itself cannot do this row-based evaluation before summing it up, at least not that I know. Do you have any suggestions how to solve this? I have tried various functions but I am not getting anywhere.

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

I was working on this before I saw the answer about SUMX. That's how you'd do with SUMX for your parameters.

SumX Example of a 'Financial Capitalization Value'[/selection of store financial capitalization
var selectedbasevalue a 'Base value'[Base value] //store base value selection
var sumxresult á sumx('Table', var comparisonvalue á 'Table'[Relevant Compensation]*0.5+selectedbasevalue //make a variable at iterated row level so don't have to calculate ittwice per iteration
return if(comparisonvalue>selectedcap, comparisonvalue)) // use the variable in both parts of IF()
return sumxresult
If this works, mark it as the solution. Congratulations are also appreciated.
Best regards
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created two measures, one is to calculate the formula you referred, and the other is to calculate the sum.

test_row_wise.PNG

Sample .pbix

 

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

mahoneypat
Employee
Employee

I was working on this before I saw the answer about SUMX. That's how you'd do with SUMX for your parameters.

SumX Example of a 'Financial Capitalization Value'[/selection of store financial capitalization
var selectedbasevalue a 'Base value'[Base value] //store base value selection
var sumxresult á sumx('Table', var comparisonvalue á 'Table'[Relevant Compensation]*0.5+selectedbasevalue //make a variable at iterated row level so don't have to calculate ittwice per iteration
return if(comparisonvalue>selectedcap, comparisonvalue)) // use the variable in both parts of IF()
return sumxresult
If this works, mark it as the solution. Congratulations are also appreciated.
Best regards
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @Anonymous ,

 

take a look at SUMX

Returns the sum of an expression evaluated for each row in a table.

https://docs.microsoft.com/en-us/dax/sumx-function-dax

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.