Forum Discussion
Time Measure Issue (Chart x Table)
we are almost there!
That worked until i replace the table row's item from "Date" to "Type" , lets suppose i do have this table:
| Type | Date | YTD_Value |
| A | 01/11/2019 | 0 |
| B | 01/11/2019 | 0 |
| A | 01/12/2019 | 1 |
| B | 01/12/2019 | 1 |
| A | 01/01/2020 | 4 |
| B | 01/01/2020 | 2 |
| A | 01/02/2020 | 3 |
| B | 01/02/2020 | 3 |
So i expect that the "Period Value" of type "A" from 01/12/2010 to 01/02/2020 = 4 (+1 of dec + 4 of jan - 1 of feb )
instead i got this:
.Pbix file
Period_Value =
IF(MONTH(Max('Calendar'[Date]))=1,
SUM(Planilha0[YTD_Value]),
SUM(Planilha0[YTD_Value]) - CALCULATE(SUM(Planilha0[YTD_Value]),PREVIOUSMONTH('Calendar'[Date]))
)
Anonymous - Wait, I'm confused. You took date away so what is the previous month in that context? Are you saying that the current month when you only have Type is the latest (max) month in the data and then previous month is 1 month before that?
I'm still not down with using PREVIOUSMONTH, it is a tricky little black box. If the above are your requirements, I would do something like:
VAR __Date = MAX([Date])
VAR __Previous = EOMONTH(__Date,-1)
VAR __PreviousYear = YEAR(__Previous)
VAR __PreviousMonth = MONTH(__Previous)
RETURN SUMX(FILTER(ALL('Table'),YEAR([Date])=__PreviousYear && MONTH([Date])=__PreviousMonth),[Column])
Then you know exactly what you are getting and how you got there versus relying on the tricky little black box that are time "intelligence" functions.