Ana Iliescu
Ana Iliescu

Reputation: 5

How to calculate the first date from a category excluding subcategory?

I would like to calculate the first date of the project, a kind of minimum. When I use MINX, everything is fine, but when I want to count how many projects have this minimum date are in Jan-2024, it doesn't calculate correctly.

This is my data I used the following measure to get the minimum date of each project

minDate= MINX(Table 1, Table 1 [Date])

Then, I counted the project which have the minimum date "Jan-2024"

Count minDate from Jan-2024 = CALCULATE(DISTINCTCOUNT(Project), FILTER(Table 1, MONTH(minDate)=MONTH(TODAY())), FILTER(Table 1,YEAR(minDate)=YEAR(TODAY()))

For Project 2 it's counting me 1 because Romania has a date from January, but it should pe zero, because the minimum date is 01/12/2023

Somehow I would like to get rid of Country in my measure.

Thanks :)

Upvotes: 0

Views: 18

Answers (1)

Sam Nseir
Sam Nseir

Reputation: 12111

Try the following:

Count minDate from Jan-2024 = 
  var sTbl = SUMMARIZE('Table 1', 'Table 1'[Project], "minDate", [minDate])
  return 
    CALCULATE(
      DISTINCTCOUNT('Table 1'[Project]),
      FILTER(
        sTbl,
        MONTH([minDate]) = MONTH(TODAY()) && 
        YEAR([minDate]) = YEAR(TODAY())
      )
    )

Upvotes: 0

Related Questions