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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.