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
Bokazoit
Post Patron
Post Patron

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
Super User
Super User

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.





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

Proud to be a Super User!






some_bih
Super User
Super User

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.





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

Proud to be a Super User!






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.

Top Solution Authors