cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bokazoit
Super User
Super User

Can this DAX be optimized?

Hi

 

I wonder if this Measure can be optimized a bit? I works as intended, but is a bit slow

Seneste betalingsmetode = 

VAR SenestBetalt = CALCULATE(
                        MAX(FactBetalingslinjer[DatoKeyStoettePeriode]), 
                        FactBetalingslinjer[#Payed Amount (GL)] > 0 
                        )

VAR BetaltMetode = CALCULATE(
                        MAX(FactBetalingslinjer[BetalingsmetodeKey]), 
                        FactBetalingslinjer[DatoKeyStoettePeriode] = SenestBetalt
                        )

VAR Metode = CALCULATE( 
                        MAX(DimBetalingsmetode[BetalingsmetodeNavn]), 
                        DimBetalingsmetode[BetalingsmetodeKey] = BetaltMetode
                        )

RETURN

Metode

I need to find the latest period based on latest payment (Variable SenestBetalt)
Then from that date I like to find the payment type (Variable BetaltMetode)
Finally I get the paymeny name from the dimension (Variable Metode)

The final part is needed (I think) because it's a starschema with all dimensions pointing at FactBetalingslinjer, so I can find the key and then get the name from the dimension.

But can it be done smarter? and can it be done faster.

 

Thanks in advance 🙂

2 REPLIES 2
some_bih
Memorable Member
Memorable Member

Hi @Bokazoit I do not understand you table name except that Fact* your fact table. If so, use ADD( SUMMARIZE pattern as variable and after that filter results.

Sarajevo, Bosnia and Herzegovina
some_bih
Memorable Member
Memorable Member

Hi @Bokazoit I do not understand you table name except that Fact* your fact table. If so, use ADD( SUMMARIZE pattern as variable and after that filter results.

Sarajevo, Bosnia and Herzegovina

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors
Top Kudoed Authors