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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.