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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate value between two dates if date falls between two dates in another table

What I am trying to accomplish create a calculated column in my date table to return the value of a column from another table where I only have a start and end date. It should be pulling in the value of 'Event Header_Basic'[POS Event Code], if DimDate[Date] is between 'Event Header_Basic'[Date Start] and 'Event Header_Basic'[Date End].

 

What I've tried is:

 

Column = CALCULATE(
            VALUES('Event Header_Basic'[POS Event Code]),
            FILTER(
                    'Event Header_Basic',
                    'Event Header_Basic'[Date Start]<=(DimDate[Date])
                      && 'Event Header_Basic'[Date End]>=(DimDate[Date])
            )
)

I recieved an error "A table of multiple values was supplied where a single value was expected.". 

 

Does anyone have any other suggestions?

 

Thanks

 

2 ACCEPTED SOLUTIONS
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use DAX below.

Column =
CONCATENATEX (
    FILTER (
        'Event Header_Basic',
        'Event Header_Basic'[Date Start] <= ( DimDate[Date] )
            && 'Event Header_Basic'[Date End] >= ( DimDate[Date] )
    ),
    'Event Header_Basic'[POS Event Code],
    ","
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

You're the best, thanks!

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use DAX below.

Column =
CONCATENATEX (
    FILTER (
        'Event Header_Basic',
        'Event Header_Basic'[Date Start] <= ( DimDate[Date] )
            && 'Event Header_Basic'[Date End] >= ( DimDate[Date] )
    ),
    'Event Header_Basic'[POS Event Code],
    ","
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have a similar case and this DAX "almost" works for me, the only challenge that I have is that I have multiple lines with multiple results, hence I end up getting something like "A,A,A,B,B,B,C,C". How can this formula be modified if I have 1 or 2 more criteria (columns) to match?

 

thanks in advance @v-chuncz-msft 

 

Rgds,

 

Fer

Anonymous
Not applicable

You're the best, thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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