'Optimize DAX measure code for days between 2 dates with the today() function
I have written the following Dax Measure that measures the amount of days between a hiring date and today and then assigns it a cateogry "1-3 months since" 4-6 months since" etc.
Tenure =
Var DageSidenStart = SUMX( 'Employee',
DATEDIFF( Employee[Employee Start Date], TODAY(),DAY )
)
Return
IF (
( ISFILTERED(Employee[Employee Code] ) || ISFILTERED( Employee[Employee Name]) && [Inbound Calls] > 0),
SWITCH(
true(),
DageSidenStart<= 90, "1-3 Måneder",
DageSidenStart > 90 && DageSidenStart<= 180, "4-6 Måneder",
DageSidenStart > 180 && DageSidenStart<= 270, "7-9 Måneder",
DageSidenStart > 270, "+12 Måneder" ),
blank()
)
However, this measure is seriously tanking my report and make the visual (A matrix) take about 6 min to load..
I dont have the option to do the today part as a calculated column, since my model is connected via live data to our data cube.
I unfornutenately cant add my dataset or modelling, since it is all confidential.
Any tips to improve the code would be a huge help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
