Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
InsightSeeker
Helper III
Helper III

Assistance Required for Calculated Column in Invoice Table

I need to create a calculated column to determine the total Invoice Amount for all sales within each invoice.

 

The calculated column should display the total Invoice Amount only for the first sale (as per the first unique key) in the invoice, while all subsequent sales should show 0. This ensures that the total amount is added only once per invoice.

 

Table 1

 

Unique_KeyCustomer_CodeInv_DateInv_NoDocumentSale_Amount
1234561234561-Jul-238675587575657871200.00
12345712345620-Jul-2386755875777886861310.00
1234581285463-Jul-2377880787686863210.00
1234591310919-Jul-2377880776576573560.00
12346013363616-Jul-2377904956998793910.00
12346113618117-Jul-23779170867868

4260.00

 

Result

 

Unique_KeyCustomer_CodeInv_DateInv_NoDocumentSale_AmountInv_Amount
1234561234561-Jul-238675587575657871200.00             2,510
12345712345620-Jul-2386755875777886861310.00                    0
1234581285463-Jul-2377880787686863210.00             6,770
1234591310919-Jul-2377880776576573560.00                    0
12346013363616-Jul-2377904956998793910.00             3,910
12346113618117-Jul-237791708678684260.00             4,260
1 ACCEPTED SOLUTION
_AAndrade
Super User
Super User

Hi @InsightSeeker,

 

Here is my solution:

Inv_Amount = 
VAR CurInvNum = 'Table'[Inv_No]
VAR TotInvAmnt = 
    CALCULATE(
        SUM('Table'[Sale_Amount]),
        FILTER('Table', 'Table'[Inv_No] = CurInvNum)
    )
VAR FirstSaleCheck = 
    CALCULATE(
        MIN('Table'[Unique_Key]),
        FILTER('Table', 'Table'[Inv_No] = CurInvNum)
    )
RETURN 
    IF('Table'[Unique_Key] = FirstSaleCheck, TotInvAmnt, 0)


Final Output:

_AAndrade_0-1716227738728.png

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

1 REPLY 1
_AAndrade
Super User
Super User

Hi @InsightSeeker,

 

Here is my solution:

Inv_Amount = 
VAR CurInvNum = 'Table'[Inv_No]
VAR TotInvAmnt = 
    CALCULATE(
        SUM('Table'[Sale_Amount]),
        FILTER('Table', 'Table'[Inv_No] = CurInvNum)
    )
VAR FirstSaleCheck = 
    CALCULATE(
        MIN('Table'[Unique_Key]),
        FILTER('Table', 'Table'[Inv_No] = CurInvNum)
    )
RETURN 
    IF('Table'[Unique_Key] = FirstSaleCheck, TotInvAmnt, 0)


Final Output:

_AAndrade_0-1716227738728.png

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors