Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
In this example table we have cumulative data for a specific cc no. and month number. Now I would want to find the actual revenue in power bi itself. For reference I have put the actual rev. value in the table
Solved! Go to Solution.
Hi @AishwariyaV
Try the below.
Column =
VAR _month = 'Table'[Month No]
VAR _previousRev =
CALCULATE(
MAX( 'Table'[cumulative rev.] ),
ALLEXCEPT( 'Table', 'Table'[cc no.] ),
'Table'[Month No] < _month
)
RETURN 'Table'[cumulative rev.] - _previousRev
HI @AishwariyaV
Sure.
Column =
VAR _month = 'Table'[Month No] --varieble captures Month no in current row
VAR _previousRev = -- varieble taht calculates previous revenue
CALCULATE(
MAX( 'Table'[cumulative rev.] ), --3 Max Revenue amount for months lower then current month
ALLEXCEPT( 'Table', 'Table'[cc no.] ), --1 ALLEXCEPT removes filter context from 'Table' apart from one on Table'[cc no.]
'Table'[Month No] < _month --2 filters table further to include months lower the one in the current row
)
RETURN 'Table'[cumulative rev.] - _previousRev
Hi @AishwariyaV
Try the below.
Column =
VAR _month = 'Table'[Month No]
VAR _previousRev =
CALCULATE(
MAX( 'Table'[cumulative rev.] ),
ALLEXCEPT( 'Table', 'Table'[cc no.] ),
'Table'[Month No] < _month
)
RETURN 'Table'[cumulative rev.] - _previousRev
Hey @Mariusz ,
Thaks fror the reply.It has solved my problem but Iam not able to understand the logic behind the query. Can you give a brief explanation of the logic so that I can extend it to my fairly big actual data set in a more informed manner.
HI @AishwariyaV
Sure.
Column =
VAR _month = 'Table'[Month No] --varieble captures Month no in current row
VAR _previousRev = -- varieble taht calculates previous revenue
CALCULATE(
MAX( 'Table'[cumulative rev.] ), --3 Max Revenue amount for months lower then current month
ALLEXCEPT( 'Table', 'Table'[cc no.] ), --1 ALLEXCEPT removes filter context from 'Table' apart from one on Table'[cc no.]
'Table'[Month No] < _month --2 filters table further to include months lower the one in the current row
)
RETURN 'Table'[cumulative rev.] - _previousRev
Hey @Mariusz ,
The DAX logic works just fine with my data-set but then I should Ideally do a lot of work at Edit Queries level like
un-pivoting,transposing etc. for that I should apply the same logic at the edit queries level. Can you help out with this prob. in a way ?
Hi @AishwariyaV
Please see the attached file with three different solutions.
Check this. Find the most recent value and subtract it
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Finding-the-most-recent-value/td-p/116838
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 65 | |
| 39 | |
| 33 | |
| 23 |