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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
himanimistry
New Member

Visual has exceeded available resources - how to optimize dax code?

Hi there, 

 

I think my DAX code is slowing down my visual, it will not load because the code is taking too long to run for each column of my table visual. How can i optimize my code or make it more efficient? 

I am creating a visual where each column shows training completion date for a course, for each employee. My dax code is broken down in two measures : 1st is to check if course is complete, 2nd is to retrieve the completion date. 2nd is the one that i show on my dashboard. The course transcript is the one i use to check completion. It is in a one - to -many relationship with my main list of employees who each have unique ID. The transcript has many courses so one employee can complete many courses. 

 

1st:

FON304 = IF(
    CALCULATE(
         COUNTROWS(RELATEDTABLE(CSPS_TRANSCRIPT)),
         FILTER(CSPS_TRANSCRIPT, CSPS_TRANSCRIPT[ NextGen Course Code] = "FON304"),
         FILTER(CSPS_TRANSCRIPT, CSPS_TRANSCRIPT[Transcript Status] = "Completed Successfully")),
         "✔"
         )
 
 2nd:
FON304 Date = MAXX(CSPS_TRANSCRIPT, FILTER(DISTINCT(CSPS_TRANSCRIPT[Transcript Completion Date]), [FON304] = "✔"))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi ALL,
Firstly  MFelix and  johnt75  thank you for yours solutions!
And @himanimistry , For your first code, you can combine the FILTER condition into a single FILTER function, which can be used to reduce the number of iterations, and you can leave out the RELATEDTABLE if the table relationships are already defined in the model. reduce the complexity of the code, as MFelix and johnt75 wrote

vxingshenmsft_1-1732501559365.png
If the amount of data is too large, using maxx will increase the computation time unnecessarily, you can try the combination of caculate and max to optimize the code.

FON304 Date(optimize) = 
CALCULATE(
    MAX(CSPS_TRANSCRIPT[Transcript Completion Date]),
    CSPS_TRANSCRIPT[NextGen Course Code] = "FON304" &&
    CSPS_TRANSCRIPT[Transcript Status] = "Completed Successfully"
)

vxingshenmsft_0-1732501443811.png

If you have further questions, check out the pbix file I uploaded, I hope it helps, and I'd be honored if I could help you out!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi ALL,
Firstly  MFelix and  johnt75  thank you for yours solutions!
And @himanimistry , For your first code, you can combine the FILTER condition into a single FILTER function, which can be used to reduce the number of iterations, and you can leave out the RELATEDTABLE if the table relationships are already defined in the model. reduce the complexity of the code, as MFelix and johnt75 wrote

vxingshenmsft_1-1732501559365.png
If the amount of data is too large, using maxx will increase the computation time unnecessarily, you can try the combination of caculate and max to optimize the code.

FON304 Date(optimize) = 
CALCULATE(
    MAX(CSPS_TRANSCRIPT[Transcript Completion Date]),
    CSPS_TRANSCRIPT[NextGen Course Code] = "FON304" &&
    CSPS_TRANSCRIPT[Transcript Status] = "Completed Successfully"
)

vxingshenmsft_0-1732501443811.png

If you have further questions, check out the pbix file I uploaded, I hope it helps, and I'd be honored if I could help you out!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

MFelix
Super User
Super User

Hi @himanimistry ,

 

Try to use the following code then you can force the condittional formatting to change the 1 into the icon that you need

FON304 = IF(

         COUNTROWS(
FILTER(
CSPS_TRANSCRIPT,
 CSPS_TRANSCRIPT[ NextGen Course Code] = "FON304" && CSPS_TRANSCRIPT[Transcript Status] = "Completed Successfully") > 0 , 1
         )
FON304 Date = MAXX(ADDCOLUMNS(CSPS_TRANSCRIPT, "FON304", [FON304]), [FON304] = 1))

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





johnt75
Super User
Super User

You can try

FON304 =
IF (
    CALCULATE (
        COUNTROWS ( CSPS_TRANSCRIPT ),
        CSPS_TRANSCRIPT[ NextGen Course Code] = "FON304",
        CSPS_TRANSCRIPT[Transcript Status] = "Completed Successfully"
    ),
    "✔"
)
FON304 Date =
VAR CompletedCourses =
    FILTER ( VALUES ( CSPS_TRANSCRIPT[Course ID] ), [FON304] = "✔" )
VAR Result =
    CALCULATE (
        MAX ( CSPS_TRANSCRIPT[Transcript Completion Date] ),
        CompletedCourses
    )
RETURN
    Result

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.