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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Simplifying dax queries that caused a lot of performance issue

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 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

please try the below two measures whether those suit your dataset.

 

Application date measure: = 
VAR _latestdate =
    MAX ( Student[Application Date] )
RETURN
    IF ( HASONEVALUE ( Student[Student ID] ), _latestdate )

 

Status expected measure: = 
VAR _maxdate = [Application date measure:]
VAR _maxstatuskey =
    CALCULATE (
        MAX ( Student[Application Status Key] ),
        Student[Application Date] = _maxdate
    )
RETURN
    IF (
        HASONEVALUE ( Student[Student ID] ),
        CALCULATETABLE (
            VALUES ( 'Status'[Status] ),
            'Status'[Application Status Key] = _maxstatuskey
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

please try the below two measures whether those suit your dataset.

 

Application date measure: = 
VAR _latestdate =
    MAX ( Student[Application Date] )
RETURN
    IF ( HASONEVALUE ( Student[Student ID] ), _latestdate )

 

Status expected measure: = 
VAR _maxdate = [Application date measure:]
VAR _maxstatuskey =
    CALCULATE (
        MAX ( Student[Application Status Key] ),
        Student[Application Date] = _maxdate
    )
RETURN
    IF (
        HASONEVALUE ( Student[Student ID] ),
        CALCULATETABLE (
            VALUES ( 'Status'[Status] ),
            'Status'[Application Status Key] = _maxstatuskey
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thank you Jihwan for the help!

amitchandak
Super User
Super User

@Anonymous , seem like you need to get the latest status. refer if my code in the blog can help

https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you for the guide sir

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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