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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
music43
Advocate II
Advocate II

Summarising

Hi

 

'Sales' is my fact table with approx 5.5M rows and the granularity is at the order item level. An order can have anywhere from 1 to 9999 lines/rows.
The carriage/freight cost for each order is recorded on the item level and as such, if an order has more than one line/row, the value is repeated.
To allow me to SUM the unique carriage cost per transaction I want to group by the 'Sales'[Transaction ID].
Additionally I have these filters

  •  'Sales'[Order Status] = "Invoiced" - To remove cancelled or incomplete orders.
  •  'Sales'[Order Carriage (GBP)] <> 0 - To remove the 300K rows without a carriage charge.

This is what I have come up with so far and it works.

 

Carriage =
VAR __InvoicedCarriage =
    FILTER(
        'Sales',
        'Sales'[Order Status]="Invoiced" 
        && 'Sales'[Order Carriage (GBP)] <> 0
    )
VAR __GroupByOrderID =
    SUMMARIZE(
        __InvoicedCarriage,
        'Sales'[Transaction Id],
        'Sales'[Order Carriage (GBP)]
    )
VAR __Result =
    SUMX(
        __GroupByOrderID,
        'Sales'[Order Carriage (GBP)]
    )
RETURN
    __Result


My questions are as follows:

1) Is there a better (more compact/efficient) way to write my formula?

2) I thought it was bad practice to filter a fact table - How else could I do this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @music43 

Thanks for @some_bih reply. You can try the following measure(compact).

Carriage =
SUMX(
    SUMMARIZE(
        FILTER(
            'Sales',
            'Sales'[Order Status] = "Invoiced"
            && 'Sales'[Order Carriage (GBP)] <> 0
        ),
        'Sales'[Transaction Id],
        'Sales'[Order Carriage (GBP)]
    ),
    'Sales'[Order Carriage (GBP)]
)

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi, @music43 

Thanks for @some_bih reply. You can try the following measure(compact).

Carriage =
SUMX(
    SUMMARIZE(
        FILTER(
            'Sales',
            'Sales'[Order Status] = "Invoiced"
            && 'Sales'[Order Carriage (GBP)] <> 0
        ),
        'Sales'[Transaction Id],
        'Sales'[Order Carriage (GBP)]
    ),
    'Sales'[Order Carriage (GBP)]
)

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

some_bih
Super User
Super User

Hi @music43 

ok for limitations of your model.

The performance / optimisation is complex task including using  Performance analyzer, DAX Studio to see and check queries.

One of option, to investigate best performance is eventually using GROUPBY, SUMMARIZE or pattern ADDCOLUMNS(SUMMARIZE

Check link as example





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






some_bih
Super User
Super User

Hi @music43 try in Power Query in pbi filter out your filter (or the best do not "import" at all) your 2 filters criteria

Sales'[Order Status]="Invoiced"

'Sales'[Order Carriage (GBP)] <>0





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Thanks @some_bih 

 

Unfortunately, I can't remove them in PQ as I need the data for other parts of the report.

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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