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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

its resolved, thanks!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors