Forum Discussion
Using active and inactive in one measure
- 4 years ago
OK, try
Turnover MTD = var mtd = DATESMTD( 'Calendar'[Date]) return CALCULATE( SUM('Table'[Turnover]), REMOVEFILTERS('Calendar'), TREATAS( mtd, 'Table'[Order date]), TREATAS( mtd, 'Table'[Delivery date]) )You may need to alter the REMOVEFILTERS if the order day & month aren't coming from the Calendar table.
You could try
Turnover MTD =
var mtd = DATESMTD( 'Calendar'[Date])
return CALCULATE( SUM('Table'[Turnover]),
TREATAS( mtd, 'Table'[Order date]),
TREATAS( mtd, 'Table'[Delivery date])
)I tried it and it gives a figure, but it's much too low. Unfortunately I couldn't find out which part of data it slices. Any idea?
- bendejnp4 years ago
Helper I
Update: Ok I found out it works only for the selected day, but it does not sum up month to date. So this part seems not to work:
var mtd = DATESMTD( 'Calendar'[Date])
- johnt754 years ago
Super User
Hmm, that could just be DAX Studio not having a context for the dates, where your report actually does.
Try
DEFINE VAR mtd = CALCULATETABLE ( DATESMTD ( 'Calendar'[Date] ), TREATAS ( { TODAY () }, 'Calendar'[Date] ) ) EVALUATE CALCULATETABLE ( 'Table', TREATAS ( mtd, 'Table'[Order date] ), TREATAS ( mtd, 'Table'[Delivery date] ) )- bendejnp4 years ago
Helper I
Sorry my last post was not regarding DAX studio. I was typing whilst you already answered. I don't have DAX studio and cannot install on my business laptop.
However I found out the formula shows only the lines order date of the selected calendar day. Example:The measure shows 435€, but it should shows 1690.
- johnt754 years ago
Super User
Try the below in DAX Studio
DEFINE VAR mtd = DATESMTD ( 'Calendar'[Date] ) EVALUATE CALCULATETABLE ( 'Table', TREATAS ( mtd, 'Table'[Order date] ), TREATAS ( mtd, 'Table'[Delivery date] ) )That will show the rows which are being summed up. If you compare that to the rows which you think should be included you might be able to see any critical differences