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

max between measure and date field

Hi,

 

I have a booking table that has bookings wiht start and end dates.  I also have two measure columns that pulls through the max and min values of a slicer on the page.

 

I am then trying to calculate the MIN between a bookings end date and the slicers max date. 

 

The measure for the slicer has a code of:

mindate = DATEVALUE((FORMAT(MIN(ssam_start_dates[date]),"dd/mm/yyyy")))

 

However if i create a column i get an error:

Function 'FORMAT' is not allowed as part of calculated column DAX expressions on DirectQuery models.

 

If i create a measure i get an error:

A single value for column 'Occupancy End' in table 'Booking SessionBedroomBedBooking' 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.

 

Capture.PNGmany thanks,

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Since you'd like to compare the dates with the slicer, you need a measure. Please refer to the two measures below. Both of them work.

Measure =
MIN (
    MAX ( 'ssam_start_dates'[Date] ),
    MIN ( 'Booking SessionBedroomBedBooking'[occupancy end] )
)
Measure 2 =
MAX (
    MIN ( 'ssam_start_dates'[Date] ),
    MIN ( 'Booking SessionBedroomBedBooking'[occupancy start] )
)

max-between-measure-and-date-field

 

Best Regards,
Dale

Community Support Team _ Dale
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

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

What does your data look like? Try this formula, please.

 

calenddate =
MIN (
    'Booking SessionBedroomBedBooking'[mindate],
    MIN ( 'Booking SessionBedroomBedBooking'[Occupancy End] )
)

Can you use this formula directly?

 

 

mindate =
DATEVALUE ( MIN ( ssam_start_dates[date] ) )

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi,

 

The data is very simple table from a SQL database,

 

Capture2.PNG

 

I also have a date table that is powering the slicer, the table is called ssam_start_dates and i am using the date column

 

If I create a Columns field I get:

 

Capture4.PNG

 

If I create a measure I get:

 

Capture5.PNG

 

What i am trying to do is find :

the MIN between the Max slicer value and the End Date

the MAX between the Min slicer value and the  Start Date.

 

Thanks,

 

 

 

 

Hi @Anonymous,

 

Since you'd like to compare the dates with the slicer, you need a measure. Please refer to the two measures below. Both of them work.

Measure =
MIN (
    MAX ( 'ssam_start_dates'[Date] ),
    MIN ( 'Booking SessionBedroomBedBooking'[occupancy end] )
)
Measure 2 =
MAX (
    MIN ( 'ssam_start_dates'[Date] ),
    MIN ( 'Booking SessionBedroomBedBooking'[occupancy start] )
)

max-between-measure-and-date-field

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.