Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Count with filtering different date columns before and after current year

I'm having an issue with a measure where I want to calculate active stores at the start of a selected year  Which I then want to visualise in a matrix with that selected year and all months.   I'v...
  • bhanu_gautam's avatar
    1 year ago

    Anonymous , Try using

    DAX
    ActiveStoresAtStartOfYear =
    VAR SelectedYear = SELECTEDVALUE(DateTable[Year])
    RETURN
    CALCULATE(
    COUNTROWS(
    FILTER(
    'StoreTable',
    'StoreTable'[OpeningDate] < DATE(SelectedYear, 1, 1) &&
    (
    ISBLANK('StoreTable'[ClosingDate]) ||
    'StoreTable'[ClosingDate] >= DATE(SelectedYear, 1, 1)
    )
    )
    ),
    REMOVEFILTERS(DateTable)
    )