Forum Discussion
Date Functions- in measures
- Anonymous5 years ago
Hi Anonymous ,
Please try to update the formula of measure [] and check whether you can get the desired result:
DeliveryItems_Last 03-06 Months =
VAR datestart =
CALCULATE (
DATEADD ( 'Calendar'[Date], -3, MONTH ),
ALL ( 'Calendar' ),
'Calendar'[Is Current Day] = TRUE ()
)
VAR datesend =
CALCULATE (
DATEADD ( 'Calendar'[Date], -6, MONTH ),
ALL ( 'Calendar' ),
'Calendar'[Is Current Day] = TRUE ()
)
RETURN
CALCULATE (
COUNT ( 'Transportation Cost'[MaterialKey] ),
Material[Material Group HL] = "Laminate"
|| Material[Material Group HL] = "Vinyl"
|| Material[Material Group HL] = "Wood",
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Date] >= datestart
&& 'Calendar'[Date] <= datesend
),
'Customer Sales'[Customer Group] <> "99"
&& 'Customer Sales'[Customer Group] <> "90"
&& 'Customer Sales'[Customer Group] <> "91"
)If the above one is not working in your scenario, please provide some sample data(exclude sensitive data) and your expected result with examples. By the way, what's the data type of field 'Calendar'[Date short]? Its data type is Date or some else type? Thank you.
Best Regards
amitchandak thanks for your help,
I am still struggling to determine where to add in the max/min date calculations, can you indicate where I should add these if I paste in the DAX text below?
Hi Anonymous ,
Please try to update the formula of measure [] and check whether you can get the desired result:
| DeliveryItems_Last 03-06 Months = VAR datestart = CALCULATE ( DATEADD ( 'Calendar'[Date], -3, MONTH ), ALL ( 'Calendar' ), 'Calendar'[Is Current Day] = TRUE () ) VAR datesend = CALCULATE ( DATEADD ( 'Calendar'[Date], -6, MONTH ), ALL ( 'Calendar' ), 'Calendar'[Is Current Day] = TRUE () ) RETURN CALCULATE ( COUNT ( 'Transportation Cost'[MaterialKey] ), Material[Material Group HL] = "Laminate" || Material[Material Group HL] = "Vinyl" || Material[Material Group HL] = "Wood", FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] >= datestart && 'Calendar'[Date] <= datesend ), 'Customer Sales'[Customer Group] <> "99" && 'Customer Sales'[Customer Group] <> "90" && 'Customer Sales'[Customer Group] <> "91" ) |
If the above one is not working in your scenario, please provide some sample data(exclude sensitive data) and your expected result with examples. By the way, what's the data type of field 'Calendar'[Date short]? Its data type is Date or some else type? Thank you.
Best Regards