Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I have table as below:
ID | Amount | Subtract from ID |
1 | -100 | 3 |
2 | 200 | |
3 | 300 | |
4 | -50 | 2 |
5 | -10 | 3 |
Can I get to the goals table below in power bi?
Goals:
ID | Amount | Subtract from ID | Final |
1 | -100 | 3 | 0 |
2 | 200 | 150 | |
3 | 300 | 50 | |
4 | -50 | 2 | 0 |
5 | -150 | 3 | 0 |
Solved! Go to Solution.
Hi, @alya1
Based on your description, I created a measure using the following DAX:
Result =
VAR _ID =
SELECTEDVALUE ( 'Table'[ID ] )
VAR _table =
SUMMARIZE (
ALL ( 'Table' ),
'Table'[ID ],
'Table'[Subtract from ID ],
'Table'[Amount ]
)
VAR _amount =
SELECTEDVALUE ( 'Table'[Amount ] )
VAR _blank =
FILTER ( _table, 'Table'[Subtract from ID ] = _ID )
RETURN
IF (
_ID IN SELECTCOLUMNS ( _blank, 'Table'[Subtract from ID ] ),
_amount + SUMX ( _blank, 'Table'[Amount ] ),
0
)
Put the corresponding column and this measure in the table visual, and the result is as follows:
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @alya1
Based on your description, I created a measure using the following DAX:
Result =
VAR _ID =
SELECTEDVALUE ( 'Table'[ID ] )
VAR _table =
SUMMARIZE (
ALL ( 'Table' ),
'Table'[ID ],
'Table'[Subtract from ID ],
'Table'[Amount ]
)
VAR _amount =
SELECTEDVALUE ( 'Table'[Amount ] )
VAR _blank =
FILTER ( _table, 'Table'[Subtract from ID ] = _ID )
RETURN
IF (
_ID IN SELECTCOLUMNS ( _blank, 'Table'[Subtract from ID ] ),
_amount + SUMX ( _blank, 'Table'[Amount ] ),
0
)
Put the corresponding column and this measure in the table visual, and the result is as follows:
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Jianpeng, thank you so much for the clean and effective DAX!
May I ask you to please explain the steps please? specifically VAR _table and the RETURN line please.
Hi, @alya1
Thank you very much for your reply. First_ID returns the ID of the current table visual row, _amount something similar:
_table generates a table of variables that looks like this:
_blank returns a table of variables that contains only the current _ID. Finally, use the SELECTCOLUMNS method to select the ID column of the _blank table, and then determine whether the _ID of the current row is in this column. If the current ID is in this table, then the amount corresponding to the current ID + the amount that matches it. That's what you're looking for.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you Jianpeng!!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
27 | |
10 | |
10 | |
9 | |
6 |