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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
villa1980
Resolver I
Resolver I

Next Available Date returning date of 31st Dec 1899

Hi all,

 

 I was kindly given this DAX formula for an issue I have returning available date based on description/bay and start date.

 It works really well, unfortunately it returns a value stated above for certain Bays.
What I would like to do is instead of the date I would like it to say "Bay Booked Out for Week".
DAX is Below.

Thanks

Min_Date =
var _Centre = SELECTEDVALUE(Next_Available_Date[Centre Name])
var _Bay = SELECTEDVALUE(Next_Available_Date[BAYDESC])
var _Date = SELECTEDVALUE(Next_Available_Date[STARTDATE])
var _Minute = SELECTEDVALUE(Next_Available_Date[Available_Minutes])
var _MinimumDate = MINX(FILTER(ALLSELECTED(Next_Available_Date),Next_Available_Date[BAYDESC]=_Bay),Next_Available_Date[STARTDATE])
RETURN
IF(
    (
        _Minute=0&&_Date>_MinimumDate
    )&&
    (
        _MinimumDate&&
        (
            _Minute>1||
            _Minute<540
        )
    ),
    _MinimumDate,
    IF(
        CALCULATE(MAX(Next_Available_Date[Available_Minutes]),FILTER(Next_Available_Date,Next_Available_Date[BAYDESC]=_Bay&&Next_Available_Date[STARTDATE]=_MinimumDate))=0&&
        CALCULATE(MAX(Next_Available_Date[Available_Minutes]),FILTER(Next_Available_Date,Next_Available_Date[BAYDESC]=_Bay&&Next_Available_Date[STARTDATE]=_Date))=0,
        _Date+1,
        _MinimumDate
    ))
1 ACCEPTED SOLUTION
anmolmalviya05
Solution Sage
Solution Sage

Hi @villa1980 , Please check the below measure:

Min_Date =
VAR _Centre = SELECTEDVALUE(Next_Available_Date[Centre Name])
VAR _Bay = SELECTEDVALUE(Next_Available_Date[BAYDESC])
VAR _Date = SELECTEDVALUE(Next_Available_Date[STARTDATE])
VAR _Minute = SELECTEDVALUE(Next_Available_Date[Available_Minutes])
VAR _MinimumDate = MINX(FILTER(ALLSELECTED(Next_Available_Date), Next_Available_Date[BAYDESC] = _Bay), Next_Available_Date[STARTDATE])

RETURN
IF (
CALCULATE(
MAX(Next_Available_Date[Available_Minutes]),
FILTER(Next_Available_Date, Next_Available_Date[BAYDESC] = _Bay && Next_Available_Date[STARTDATE] = _MinimumDate)
) = 0 &&
CALCULATE(
MAX(Next_Available_Date[Available_Minutes]),
FILTER(Next_Available_Date, Next_Available_Date[BAYDESC] = _Bay && Next_Available_Date[STARTDATE] = _Date)
) = 0,
"Bay Booked Out for Week",
IF (
_Minute = 0 && _Date > _MinimumDate && (_Minute > 1 || _Minute < 540),
_MinimumDate,
IF (
_Minute = 0,
_Date + 1,
_MinimumDate
)
)
)

 

View solution in original post

2 REPLIES 2
anmolmalviya05
Solution Sage
Solution Sage

Hi @villa1980 , Please check the below measure:

Min_Date =
VAR _Centre = SELECTEDVALUE(Next_Available_Date[Centre Name])
VAR _Bay = SELECTEDVALUE(Next_Available_Date[BAYDESC])
VAR _Date = SELECTEDVALUE(Next_Available_Date[STARTDATE])
VAR _Minute = SELECTEDVALUE(Next_Available_Date[Available_Minutes])
VAR _MinimumDate = MINX(FILTER(ALLSELECTED(Next_Available_Date), Next_Available_Date[BAYDESC] = _Bay), Next_Available_Date[STARTDATE])

RETURN
IF (
CALCULATE(
MAX(Next_Available_Date[Available_Minutes]),
FILTER(Next_Available_Date, Next_Available_Date[BAYDESC] = _Bay && Next_Available_Date[STARTDATE] = _MinimumDate)
) = 0 &&
CALCULATE(
MAX(Next_Available_Date[Available_Minutes]),
FILTER(Next_Available_Date, Next_Available_Date[BAYDESC] = _Bay && Next_Available_Date[STARTDATE] = _Date)
) = 0,
"Bay Booked Out for Week",
IF (
_Minute = 0 && _Date > _MinimumDate && (_Minute > 1 || _Minute < 540),
_MinimumDate,
IF (
_Minute = 0,
_Date + 1,
_MinimumDate
)
)
)

 

Ritaf1983
Super User
Super User

Hi @villa1980 

Please provide a workable sample data and your expected result from that. It is hard to figure out what you want to achieve from the description alone.  

https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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