cancel
Showing results for
Did you mean:
Regular Visitor

## Help me optimize calculation for unique value in another column!

In this simplified example I am selling item A and B.

I have a fact table with sales and discount amounts.

Sales and discounts have different granularity. One sale can have several discount types. In this example types X, Y and Z.

It is all merged in to one table.

So I need to calculate salesamount for each unique SalesId to get the correct amount.

I solved it like this:

MaxSales = MAX(Tabell1[Amount])

SalesAmount = SUMX(VALUES(Tabell1[SalesId]);[MaxSales])

SalesAmount over DiscountType and Item is calculated as I want it to.

However, it is quite slow!

I am doing this in SSAS Tabular with a fact table with 500 million rows. Is there any way to do this more efficiently?

I tried splitting discounts and sales into two separate fact tables with a relation between but it worked horrible.

Help is much appreciated!

3 REPLIES 3
Community Support Team

## Re: Help me optimize calculation for unique value in another column!

Hi @fovesson,

The measures could perform well in your scenario. As the formula is simple enough.To imporve the performance, we should optimizate the data from the data source. For example to reduce useless rows.

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Community Support Team

## Re: Help me optimize calculation for unique value in another column!

Hi @fovesson,

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Regular Visitor

## Re: Help me optimize calculation for unique value in another column!

Hi Frank

Nah, there are no useless rows to clean.

I tried the FIRSTNONBLANK function instead of MAX in hope of better performance but it was slightly slower to my surprise.

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!