Forum Discussion
Interation by rows applying a logical condition
What function can be used to interate row by row evaluating an expression and if a condition is applied, the value of the expression is added...
For Example: an account number(row data), with an amount that compared to the previous month gives a negative or positive variation (expression) , if la is < 0 (negative), add it up... So the result is only the negatives added
Hi Aluisjara86 ,
If you want to calculate the cumulative value of the measure, please try the formula:
Cumulative Cur-Pre = IF ( [Cur-Pre] < 0, SUMX ( FILTER ( ALLSELECTED ( Dates[Month] ), [Cur-Pre] < 0 && Dates[Month] <= MAX ( Dates[Month] ) ), [Cur-Pre] ) )And if you want to calculate the cumulative value of the sales, please try the formula:
Cumulative Sales = CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL ( Dates ), Dates[Month] <= MAX ( Dates[Month] ) && [Cur-Pre] < 0 ) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- edhansCommunity Champion
Try this:
SomeMeasure = CALCULATE( SUM( table[Column] ), Table[Column] < 0 )- Aluisjara86New Member
Thanks, but the value that I want yo sum is not in a column, actually is the result of a measure (amount actual year - amount previous year)
- edhansCommunity Champion
SomeMeasure = CALCULATE( [Another Measure], Table[Column] < 0 )Ok, try the above. If that isn't what you want, please provide data so we aren't guessing about what is going on.
How to get good help fast. Help us help you.
How To Ask A Technical Question If you Really Want An Answer
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
- v-kkf-msftCommunity Support
Hi Aluisjara86 ,
If you want to calculate the cumulative value of the measure, please try the formula:
Cumulative Cur-Pre = IF ( [Cur-Pre] < 0, SUMX ( FILTER ( ALLSELECTED ( Dates[Month] ), [Cur-Pre] < 0 && Dates[Month] <= MAX ( Dates[Month] ) ), [Cur-Pre] ) )And if you want to calculate the cumulative value of the sales, please try the formula:
Cumulative Sales = CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL ( Dates ), Dates[Month] <= MAX ( Dates[Month] ) && [Cur-Pre] < 0 ) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.