Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Lookup value if date is between two dates

Hi   I'm new to PowerBI and the DAX syntax. I have 2 tables (Sprints and WorkItems). All date columns are formatted as Date   Sprints table: (columns StartDate, FinishDate and SprintNumber) ...
  • Anonymous's avatar
    Anonymous
    7 years ago

    I don't think you've told us all about the model... I suspect there are relationships between the two tables based on the date fields.

     

    Try this

    CreatedInSprint =
    var __date = WorkItems[fields_SystemCreatedDate]
    return
    	MAXX(
    		FILTER(
    			Sprints;
    			AND(
    		    	Sprints[attributes_startDate] <= __date,
    		    	__date <= Sprints[attributes_finishDate]
    		    )
    		),
    		Sprints[SprintNo]
    	)

    This should work correctly on the assumption that there is always at most one sprint returned by the logical condition in FILTER. If there happen to be many, then the maximum SprintNo will be returned.

     

    Best

    Darek