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
vengadesh_p
Helper I
Helper I

How to improve Performance for this Dax

Hi All

I Have two tables, Dim_Calendar & Fact_EwContract. There is no relationship between them  

I want to find an Active contract based on Dim_Calendar Date Selection

So I created this Dax, But it took a very long time to load data in table view,

I Need some alternate solution for this Dax

vengadesh_p_0-1728980508838.png

 

2 ACCEPTED SOLUTIONS
shafiz_p
Super User
Super User

Hi @vengadesh_p  Try this:

ActiveContracts =
VAR StartofThisPeriod = LASTDATE(Dim_Calendar[Month Start Date])
VAR EndofThisPeriod = ENDOFMONTH(StartofThisPeriod)
RETURN
CALCULATE(
    [# Contracts],
    KEEPFILTERS(
        Fact_EwContract[Contracts Start Month] <= StartofThisPeriod &&
        Fact_EwContract[Contracts End Month] > EndofThisPeriod
    )
)

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution!!

 

 

Best Regards,
Shahariar Hafiz

View solution in original post

danextian
Super User
Super User

Hi @vengadesh_p 
The very obvious reason causing a performance problem here is that you are filtering a table when you only need to filter a column or columns. @shafiz_p has provided a good example on how to apply a filter over a column but still keep  the row context.  You can also refer this blog: https://www.sqlbi.com/articles/using-keepfilters-in-dax/ 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
sergej_og
Super User
Super User

Hey @vengadesh_p ,
why there is no relationship between the two tables.
The fastest way for a measure is to use the relationship between the tables to apply the measure logic.

Btw using FILTER() is not that bad.
I had cases where FILTER() worked faster than filtering a specific column.
You have to figure out for your needs.

Regards

danextian
Super User
Super User

Hi @vengadesh_p 
The very obvious reason causing a performance problem here is that you are filtering a table when you only need to filter a column or columns. @shafiz_p has provided a good example on how to apply a filter over a column but still keep  the row context.  You can also refer this blog: https://www.sqlbi.com/articles/using-keepfilters-in-dax/ 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
shafiz_p
Super User
Super User

Hi @vengadesh_p  Try this:

ActiveContracts =
VAR StartofThisPeriod = LASTDATE(Dim_Calendar[Month Start Date])
VAR EndofThisPeriod = ENDOFMONTH(StartofThisPeriod)
RETURN
CALCULATE(
    [# Contracts],
    KEEPFILTERS(
        Fact_EwContract[Contracts Start Month] <= StartofThisPeriod &&
        Fact_EwContract[Contracts End Month] > EndofThisPeriod
    )
)

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution!!

 

 

Best Regards,
Shahariar Hafiz

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.