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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
InsightSeeker
Helper II
Helper II

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.