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
Alex_Ooi
Helper IV
Helper IV

Using measures to return data grouped by specific date ranges

Hi folks,

I want to create a measure called Total Bookings by Campaign Period, which I am stuck at the moment. The closest I could get to this is using the measure below:

Overall # Bookings = CALCULATE([# Bookings],
    ALLEXCEPT(Sales,Sales[Site Name],dCalendar[Calendar Date]))

By filtering my date ranges on the slicer to be the same with the campaign period, I would expect the first row to return a result of 4,354.

 

Group by Campaign Dates.png 

My challenge is to group the booking counts (that contains booking dates in Sales table) into Campaign Start Date and Campaign End Date (which are from the Promo table). I tried writing this but it returns an error for me.

Total Bookings by Campaign Period = CALCULATE([# Bookings],
    ALLEXCEPT(Sales,Sales[Site Name],
        DATESBETWEEN(Sales[Booking Date], PromoCodes[Booking From], PromoCodes[Booking To]))

 Below is the error message:

"A single value for column 'Booking From' in table 'PromoCodes' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

I have no idea why RELATED does not work in my formula above either. After many rounds of research, I am still not able to find light at the end of the DAX tunnel.

 

Please advise. Thanks.

16 REPLIES 16

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.