March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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
Solved! Go to Solution.
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
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/
Proud to be a 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
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/
Proud to be a 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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |