Forum Discussion
Date range in Direct Query mode
- Anonymous6 years ago
Hi Anonymous ,
You can create one measure as below, please find full details in my sample PBIX file.
1. Get the value of the date columns in that two tables separately
2. Calculate the number of days between these two dates
GetDateRange =
VAR a =
MAX ( '001_t1'[ID] )VAR sdate =
CALCULATE ( MAX ( '001_t1'[Start date] ), '001_t1'[ID] = a )
VAR edate =
CALCULATE (
MAX ( '001_t2'[End Date] ),
FILTER ( '001_t2', '001_t2'[PID] = a )
)
VAR Ddiff =
DATEDIFF ( sdate, edate, DAY )
RETURN
Ddiff
If the above formula is not applicable in your scenario, please provide me the related table structure and sample data.
Best Regards
Rena
Hi Anonymous ,
You can create one measure as below, please find full details in my sample PBIX file.
1. Get the value of the date columns in that two tables separately
2. Calculate the number of days between these two dates
GetDateRange =
VAR a =
MAX ( '001_t1'[ID] )VAR sdate =
CALCULATE ( MAX ( '001_t1'[Start date] ), '001_t1'[ID] = a )
VAR edate =
CALCULATE (
MAX ( '001_t2'[End Date] ),
FILTER ( '001_t2', '001_t2'[PID] = a )
)
VAR Ddiff =
DATEDIFF ( sdate, edate, DAY )
RETURN
Ddiff
If the above formula is not applicable in your scenario, please provide me the related table structure and sample data.
Best Regards
Rena
- lovishsood14 years agoResolver I
Hi,
I have the same query but instead of the count of days, I want to list all the dates between two dates(if exist).
Eg.:Start Date = Feb,5,2022 End Date = Feb 8,2022
Output : Feb 5,2022
Feb 6,2022
Feb 7,2022
Feb 8,2022