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! Get ahead of the game and start preparing now! Learn more
Here's my issue: I have a formula calculating a refund amount by product for over/under consumption. Idea is refund/charge for more than 10% over/under consumption:
Refund/Charge = (switch(TRUE(),[Consumption Qty]<[Allocation -10%],[Allocation-Consumption]-[Allocation]*.10,[Consumption Qty]>[Allocation +10%],[Allocation-Consumption]+[Allocation]*.10,0))*[Net Price]
The formula works just fine by chemical:
Output
Chemical 1 (3940)
Chemical 2 250
Chemical 3 (45) etc
The problem is, I need a total too. Total given is $7, but total of refund/charge for each chemical (adding each line item) is 10,319.
Assuming you are using this in something like a table/matrix and that this is a measure, you often have to change how this is calculated in the context of ALL. Typically do this with an IF statement and HASONEFILTER or HASONEVALUE I believe, it is a pretty common issue.
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
the problem is hasonevalue applies to columns, not measures.
Using a column isn't realistic in this case. I'd like something that does the same thing for a measure.
Use HASONEFILTER.
HASONEFILTER(switch(TRUE(),[Consumption Qty]<[Allocation -10%],[Allocation -10%]-[Consumption Qty],[Consumption Qty]>[Allocation +10%],[Allocation-Consumption]+[Allocation]*.10,0))*[Net Price])
Nope. Still asks me for a column.
The original formula is a composite of measures built from columns in multiple tables.
I need the total to be in terms of product. Add line 1, 2, 3, etc. just like I could do in excel.
Is there an option for "aggregate by product" or something?
You need to post sample/mock data. What I am referring to is to is to have a table in which you have Product.
IF(HASONEFILTER([Product]), calculate one way, calculate another way)
It sounds like the issue is that your table is correct except for the totals.
Allocation Table
[vessel]
[chemical]
[allocation]
allocation bridge (combinding items from allocation and main tables)
[vessel]
[chemical]
[allocation]
main table
[vessel]
[chemical]
[consumption]
[date]
Allocation measure = sum('allocation bridge'[allocation])
consumption qty measure = sumx('main',[qty]*[xqty])
Refund/Charge = (switch(TRUE(),[Consumption Qty]<[Allocation -10%],[Allocation -10%]-[Consumption Qty],[Consumption Qty]>[Allocation +10%],[Allocation-Consumption]+[Allocation]*.10,0))*[Net Price]
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |