Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Comparision of date in range of dates

I am working on two tables Events & Events_Summary:

 

I want to compare an event date between the start date and end date of every cycle and then display the cycle name for every event. If there is no cycle on that date of the event, then we display 'No-Cycle'.  Can anyone help me with any solution in DAX? Is there any lookup for this 

 

My Data looks like this

Events

bharathkarre_0-1601313659159.png

 

 

Events_Summary

bharathkarre_1-1601313681135.png

 

 

Desired Output in Events_Table

bharathkarre_2-1601313702240.png

 

2 REPLIES 2
Anonymous
Not applicable

[Cycle] = // calc column in Events
var __date = Events[Event_Date]
var __filteredForCycles =
    filter(
        Events_Summary,
        Events_Summary[Cycle_Start_Date] <= __date
        &&
        __date <= Events_Summary[Cycle_End_Date]
    )
var __cycleCount =
    COUNTROWS( __filteredForCycles )
var __cycle =
    MAXX(
        __filteredForCycles,
        Events_Summary[Cycyle_Name]
    )
var __output =
    switch( TRUE(),
        __cycleCount = 1, __cycle,
        __cycleCount = 0, "No-Cycle",
        
        // If your table has mutually exclusive
        // cycles, this should not happen.
        "Many Cycles"
    )
return
    __output
HotChilli
Super User
Super User

Create a table visual holding the columns of the 1st table.

Create  a measure as follows:

Create a variable to hold event_date -> _edate

Create a variable to find the cycle_name in the 2nd table by filtering the 2nd table to find row where cycle_start_date < edate and cycle_end_date > edate. -> _cycleName

 

If _cycleName is empty return "No-cycle" otherwise return _cycleName

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.