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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
musafasih
Frequent Visitor

Filtering rows , calculating freight as a % of sales

Hi,

So here is my issue: I have one column for invoices, and another for transaction category. My invoice column consists of a number of invoices, for each invoice number, there could be 2 to 3 rows in the dataset, denoting different categories of transactions for the same invoice. The transaction category column consists of multiple categories, one of them being Freight costs. All invoices having Freight costs also have other transaction categories as well, but not all invoices have freight costs. I want to isolate the invoices having freight costs, but in such a way that not only the freight transactions are returned, but also other transactions associated with those invoices are returned, so that I am able to calculate freight as a percentage of sales only for invoices having freight. Thanks.

1 ACCEPTED SOLUTION
jameszhang0805
Resolver IV
Resolver IV

@musafasih  Not sure if this is the result you want
Virtual Data Source

jameszhang0805_0-1614063104212.png

Measure of Freight Invoice Amount

 

FreightInvoiceAmt = 
VAR _FreightInvoice =
    CALCULATETABLE (
        SUMMARIZE ( 'Table', 'Table'[Invoice#] ),
        'Table'[Category] = "Freight"
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        TREATAS ( _FreightInvoice, 'Table'[Invoice#] ),
        ALLEXCEPT ( 'Table', 'Table'[Invoice#] )
    )

 

jameszhang0805_0-1614063733886.png

Filtering rows , calculating freight as a % of sal....pbix 

 

View solution in original post

4 REPLIES 4
jameszhang0805
Resolver IV
Resolver IV

@musafasih  Not sure if this is the result you want
Virtual Data Source

jameszhang0805_0-1614063104212.png

Measure of Freight Invoice Amount

 

FreightInvoiceAmt = 
VAR _FreightInvoice =
    CALCULATETABLE (
        SUMMARIZE ( 'Table', 'Table'[Invoice#] ),
        'Table'[Category] = "Freight"
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        TREATAS ( _FreightInvoice, 'Table'[Invoice#] ),
        ALLEXCEPT ( 'Table', 'Table'[Invoice#] )
    )

 

jameszhang0805_0-1614063733886.png

Filtering rows , calculating freight as a % of sal....pbix 

 

Thats exactly what I wanted! thanks alot!!!!! 😊

amitchandak
Super User
Super User

@musafasih ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

its resolved, thanks!!!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.