Forum Discussion
Time Intelligence conflict in two measures
Hi,
I have a report that uses a Measure to calculate a cumulative number based on time. I have a calendar tables shared across all tables. My issue is that a measure with time intelligence (TI) using another measure with a different time Intelligence will be confused. I need help to find a way to allow the original TI to not be filtered out by the using measure.
The Cumulative measure is blow and it works just fine.
**bleep** Delivery = CALCULATE(
SUM('i0026 AUX_MAT_DLV_PRD'[QUANTITY]),
FILTER(ALLSELECTED('Calendar'),
'Calendar'[Date] <= MAX('Calendar'[Date])))
I also have a another measure to count all failures:
Failure# =
DISTINCTCOUNT('i0026 PROD_REPAIR'[UNIT_NO_TXT])
I need to calculate a Monthly rate (which is failure# divided by **bleep** Delivery) and the measure below works perfectly per month in a time table.
MRR % =
DIVIDE(
[Failure#],[**bleep** Delivery])
The issue I have is when I want to calculate a 3 months rolling average of that MRR%. The measure below don’t work
3mra MRR % =
CALCULATE(
[MRR %],
DATESINPERIOD ('Calendar'[Date],LASTDATE('Calendar'[Date]),-3,MONTH)
)
I think because it DATEINPERIOD filters the measure [**bleep** Delivery] in addition to the original time filter it has:
FILTER(ALLSELECTED('Calendar'),
'Calendar'[Date] <= MAX('Calendar'[Date])))
Please advise.
8 Replies
- v-eachen-msft
Community Support
Hi bdn008 ,
You could try DATESBETWEEN(). Here are the codes for your reference.
Measure 2 = VAR __EndDate = EOMONTH ( LASTDATE ( 'Table'[Date] ), 0 ) VAR __StartDate = DATE ( YEAR ( __EndDate ), MONTH ( __EndDate ) - 3, 1 ) RETURN CALCULATE ( [Measure], DATESBETWEEN ( 'Table'[Date], __StartDate, __EndDate ) )- bdn008
Advocate II
v-eachen-msft Thanks for the reply BUT this did not solve the issue.
DATESBETWEEN worked very similarly to DATESINPERIOD.
The Issue is how to allow different time filtering on the second measure WHILE maitaining the original time filtering on the first Measure. IfI had a calculated table that will result in a value in the fact table, maybe it would work. But I really prefer to use a measure. Also, I kno the ALLSELECT in the first measure is the issue but I still need to allow both measures to work.
Still hoping to get some ideas...
- mahoneypat
Microsoft Employee
You should be able to make a virtual table of your last 3 months (or the days in the last 3 months) and use AVERAGEX over that table to get your desired result. Doing it at the month level will be less calculation intensive, but you can replace the YearMonth column with Date level, if needed. For example
NewMeasure = VAR __last3months = CALCULATETABLE ( VALUES ( 'Calendar'[YearMonth] ), DATESINPERIOD ( 'Calendar'[Date], LASTDATE ( 'Calendar'[Date] ), -3, MONTH ) ) RETURN AVERAGEX ( __last3months, DIVIDE ( [Failure#], [**bleep** Delivery] ) )If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat