Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Calculated dates between two dates and modify them to the Range

$
0
0

I have a peculiar requirement where we have start and end dates for a Report. So, when the user selects the start and end dates in the report, they should be able to retrieve all the records if it either falls under start date or end date and correct the dates accordingly later. I would need this accomplished in a DAX Query.

Below is just an example of how the Dataset looks like:

CREATETABLE#Promos([ProductNumber]       INT,[StartDate]           DATE,[EndDate]             DATE,[PromoCode]           VARCHAR(6),[DaysAvailableInWeek] VARCHAR(20));INSERTINTO#Promos ([ProductNumber],[StartDate],[EndDate],[PromoCode],[DaysAvailableInWeek])VALUES(6512,'2020-01-11','2020-01-13','ABC123','1, 3, 5');INSERTINTO#Promos ([ProductNumber],[StartDate],[EndDate],[PromoCode],[DaysAvailableInWeek])VALUES(6514,'2020-01-12','2020-01-14','ABC123','4, 6');

Example:

SELECT*FROM#Promos WHERE[StartDate]='2020-01-12'AND[EndDate]='2020-01-14';

The Expected output for the above query should be:

ProductNumber StartDate   EndDate     PromoCode   DaysAvailableInWeek65142020-01-122020-01-14  ABC123      4,665122020-01-122020-01-13  ABC123      1,3,5



Known is a DROP, Unknown is an OCEAN.


Viewing all articles
Browse latest Browse all 14337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>