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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Simplifying DAX Code

Hi All, My PBI reports are working just fine but the problem is, it's having performance issue in my actual pbi, loading takes too much of time. But in my mockup pbi it's working fine. i think this is due to long queries of the dax measures. 

 

Two measure that's needing simplifications

1. 

Status expected measure: =
VAR _latestdate =
    CALCULATE (
        MAX ( Student[Application Date] ),
        ALLEXCEPT ( Student, Student[Student ID] )
    )
VAR _maxstatuskey =
    MAXX (
        FILTER (
            ALL ( Student ),
            Student[Student ID] = MAX ( Student[Student ID] )
                && Student[Application Date] = _latestdate
        ),
        Student[Application Status Key]
    )
RETURN
    IF (
        HASONEVALUE ( Student[Student ID] ),
        CALCULATETABLE (
            VALUES ( 'Status'[Status] ),
            'Status'[Application Status Key] = _maxstatuskey
        )
    )
 
 
2. 
Application date measure: =
VAR _latestdate =
    CALCULATE (
        MAX ( Student[Application Date] ),
        ALLEXCEPT ( Student, Student[Student ID] )
    )
RETURN
IF( HASONEVALUE(Student[Student ID]),
    _latestdate)
 
Mockup result which is correct:

ameng_0-1660066280539.png

pbi file 

I need to apply the same logic from the mockup pbi to my actual pbi and it's having performance issues, and i believe this is due to the long dax queries.Hoping that someone can guide me on this, thank you!

1 REPLY 1
colacan
Resolver II
Resolver II

Hi, propably the perfermance issue casued by

    MAXX (    <== Iterator
        FILTER (        <== Iterator
            ALL ( Student ),     <==  all Student table
you are using nested iterator which means it double iterates all student table. the quick kill would be All(Student[Student ID], Student[Application Date]) instead of iterating ALL(Student) table. even batter way is try to  avoid using nested iterator for big table.
I recommend to watch this video:   https://www.youtube.com/watch?v=UtDP8KnWXy8
 
I hope this helps you.
Thank you

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.