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
aj1973
Community Champion
Community Champion

A chart with 2 date columns

Hi,

I have a table with 2 columns of dates(arrival dates and departure dates) and a measure.

The arrival date has to be <= Today()

The departure date has to be in the next 6 months and not including today

The measure is to calculate number of rooms occupied every day(I used the 2 filters of arrival date and deparutre date to calaculate).

 

The question is : how to make a chart Graph to see the measure of every day/month in the future? only one DATE on AXIS

 

Thank you 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

1 ACCEPTED SOLUTION

Hi @aj1973,

 

Try this formula, please. It's a data type issue. It's DateTime in details while it's Date in the date table. So the calculation range is wrong.

Room_Occupied 2 =
IF (
    MIN ( 'Calendar'[Date] ) < TODAY (),
    BLANK (),
    CALCULATE (
        DISTINCTCOUNT ( V_Reservations_Amine[OpReserv_ID] ),
        FILTER (
            'V_Reservations_Amine',
            'V_Reservations_Amine'[Reserv_DateArr].[Date] <= MIN ( 'Calendar'[Date] )
                && 'V_Reservations_Amine'[Reserv_DateDep].[Date] > MIN ( 'Calendar'[Date] )
                && 'V_Reservations_Amine'[Reserv_DateArr].[Date] <= TODAY ()
                && 'V_Reservations_Amine'[Reserv_DateDep].[Date] > TODAY ()
        )
    )
)

A_chart_with_2_date_columns

 

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

11 REPLIES 11
v-jiascu-msft
Employee
Employee

Hi @aj1973,

 

We can create a date table and create two relationships between it and the table. Then create a measure with function USEREALTIONSHIP. Please share a dummy sample. We can build a solution.

 

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.

hi Dale

 

 

 

 

 

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi Amine,

 

Can you provide a dummy sample?

 

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.

Capture3.PNG

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi @aj1973,

 

Please provide the original-like data. You can create a dummy. 

Maybe you can check out the demo in the attachment. You can modify it to the scenario of yours. 

1. Delete the relationship between Date table and the fact table. Or create a new independent Date table.

2. Create a measure like below.

RoomOccupied =
IF (
    MIN ( 'Calendar'[Date] ) < TODAY (),
    BLANK (),
    CALCULATE (
        DISTINCTCOUNT ( Table1[OpReserv_ID] ),
        FILTER (
            'Table1',
            'Table1'[Reserv_DateArr] <= MIN ( 'Calendar'[Date] )
                && 'Table1'[Resrv_DateDep] >= MIN ( 'Calendar'[Date] )
                && 'Table1'[Reserv_DateArr] <= TODAY ()
                && 'Table1'[Resrv_DateDep] > TODAY ()
        )
    )
)

a_chart

 

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.

Hi Dale,

 

Sorry for not replying yesterday (did not go to work).

Your solution worked fine but with a slight Time Lag between results:

 

  • here is how it should be What I need to see.PNG

 

  • and here is what i got out of your codeTime Lag VS Results.PNG

 

Don't know if i should bother you again but i will try to figure it out.

 

Thank you very much

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi @aj1973,

 

Please reproduce the issue based on the demo I shared with you. Or share your data. I tried but can't find out what's going wrong from the snapshots.

 

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.

Hi Dale,

Thank you for your patience. here I share with you the Data in Dummy.pbix. I also joined some Snapshot of the data in our Application. 

https://drive.google.com/file/d/1hCehpjeocUghhGcGRAwYXaMaupCwsbbs/view?usp=sharing

 

Some snapshots

https://drive.google.com/drive/folders/1pSjWJX3SNCOl7SHVHoCtAMXcq_WrnAaQ?usp=sharing

 

Today, to the contrary of yesterday i found out that the numbers in the visual of Rooms Checked IN  are coming out for some Sites( Site ID= 8 , 14, and 13) incorrect and for the Site ID=11 "correct" but of course with a Time lag of one day.

 

For the visual Rooms sold the numbers are coming out correct but with a Time lag of one day

 

let me know if you needed more details

 

Thanks a lot

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi @aj1973,

 

Try this formula, please. It's a data type issue. It's DateTime in details while it's Date in the date table. So the calculation range is wrong.

Room_Occupied 2 =
IF (
    MIN ( 'Calendar'[Date] ) < TODAY (),
    BLANK (),
    CALCULATE (
        DISTINCTCOUNT ( V_Reservations_Amine[OpReserv_ID] ),
        FILTER (
            'V_Reservations_Amine',
            'V_Reservations_Amine'[Reserv_DateArr].[Date] <= MIN ( 'Calendar'[Date] )
                && 'V_Reservations_Amine'[Reserv_DateDep].[Date] > MIN ( 'Calendar'[Date] )
                && 'V_Reservations_Amine'[Reserv_DateArr].[Date] <= TODAY ()
                && 'V_Reservations_Amine'[Reserv_DateDep].[Date] > TODAY ()
        )
    )
)

A_chart_with_2_date_columns

 

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.

Perfect.

 

Thak you very much Dale

 

Amine

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

It's my pleasure, Amine. Could you please mark my answer as a solution?

 

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.