Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
All
Problem:
I need to allocate the discount to invoice line items, but there are cases when the discount is credited in separate credit memo and has only one invoice line as a result. Then I need to make sure that those lines will be summarized in my column called "AdjustedAmountInvoiceLineItem" using countif function. I tried several DAX commands like COUNT, COUNTA, COUNTROWS in combination with FILTER, ALL, ALLEXCEPT to no avail so far.
| Discount | invoiceNumber | serviceMonth | Sum of Total | AllocatedDiscountperInvoiceLine | AdjustedAmountInvoiceLineItem |
| -660 | 12345 | 04/2021 | -660 | 0 | -660 |
| -400 | 12478 | 05/2021 | 4000 | -200 | 3800 |
| -200 | 12478 | 05/2021 | 2000 | -50 | 1950 |
Right now, the value in the last column is zero, but should be -660 EUR.
So this is my current DAX Command:
AdjustedAmountInvoiceLineItem = IF(AND(Table1[Discount]="Discount", Calculate(COUNT,ALLEXCEPT(Table1, Table1[invoiceNumber], Table1[serviceMonth])>1)),0,Table1[Sum of Total]+Table1[AllocatedDiscountPerInvoiceLine])
But I get this error message:
The syntax for ',' is incorrect. (DAX(IF(AND(Table1[Discount]="Discount",Calculate(COUNT,ALLEXCEPT(Table1[invoiceNumber], Table1[serviceMonth])>1)),0,Table1[Sum of Total]+Table1[AllocatedDiscountPerInvoiceLine]))).
I cannot see the error and I am not sure if this is the correct DAX command at all.
I appreciate all the help!
Thanks!
GracieLee
Solved! Go to Solution.
All,
found it, here is the DAX Command I used:
IF(AND(Table1[Discount]="Discount", Calculate(COUNTROWS(Table1),ALLEXCEPT(Table1,Table1[serviceMonth],Table1[invoiceNumber]))>1),0, Table1[Sum of Total]+Table1[AllocatedDiscountPerInvoiceLine])
Have a great day!
Regards
GracieLee
Noticed that you have resolved this issue by yourself. Could you please kindly mark your solution to help the other members find it more quickly? Thanks in advance!
Best Regards,
Community Support Team _Caiyun
All,
found it, here is the DAX Command I used:
IF(AND(Table1[Discount]="Discount", Calculate(COUNTROWS(Table1),ALLEXCEPT(Table1,Table1[serviceMonth],Table1[invoiceNumber]))>1),0, Table1[Sum of Total]+Table1[AllocatedDiscountPerInvoiceLine])
Have a great day!
Regards
GracieLee
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 9 | |
| 7 | |
| 5 |