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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.