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
Anonymous
Not applicable

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.

 

 2019-01-18 09_13_47-test–Power BI Desktop.png

 

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.

 

2019-01-18 09_22_47-test–Power BI Desktop.png

 

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
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

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.
Anonymous
Not applicable

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.

v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

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.

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.