Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
I have 2 tables Payment and Sales.
The Payment table has Payment and Write-Off columns that I want to add to the Sales table.
Now the issue is the amounts could be either positive or negative.
Relationship is Payment(many) ---> Sales (one)
So I know I have to use the relatedtable. I added the field to the Sales table using the following:
maxx(RELATEDTABLE(Payment), Payment[Write-Off Amount])
But now I am not sure how to change the code so that ifthe Write-Off amount is positive instead of grabbing the max, the code will grab the min and when it is positive it will grab the max? Is this even possible in Power BI?
Solved! Go to Solution.
Measure =
VAR _sum = SUM(Payment[Write-Off Amount]))
VAR _maxx = MAXX(RELATEDTABLE(Payment),Payment[Write-Off Amount])
VAR _minx = MINX(RELATEDTABLE(Payment),Payment[Write-Off Amount])
RETURN IF(_sum<0,_minx,_maxx)
@newkingdom can you try the above?
Measure =
VAR _sum = SUM(Payment[Write-Off Amount]))
VAR _maxx = MAXX(RELATEDTABLE(Payment),Payment[Write-Off Amount])
VAR _minx = MINX(RELATEDTABLE(Payment),Payment[Write-Off Amount])
RETURN IF(_sum<0,_minx,_maxx)
@newkingdom can you try the above?
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 52 | |
| 41 | |
| 32 | |
| 26 | |
| 24 |
| User | Count |
|---|---|
| 132 | |
| 118 | |
| 57 | |
| 45 | |
| 43 |