Sunday, August 26, 2018

How to use DATESBETWEEN Function in Power BI DAX

DATESBETWEEN Function (DAX)
The is Function returns a table that contains a column of dates that begins with the start_date and continues until the end_date.

Syntax :
DATESBETWEEN(<dates>,<start_date>,<end_date>) 

dates - is reference to a date/time column.
start_date - is a date expression.
end_date - is a date expression.

Remarks
If start_date is a blank date value, then start_date will be the earliest value in the dates column.
If end_date is a blank date value, then end_date will be the latest value in the dates column.
The dates used as the start_date and end_date are inclusive: that is, if the sales occurred on September 1 and you use September 1 as the start date, sales on September 1 are counted.

Example :
The following sample DAX formula creates a measure that calculates the 'Q4FY16 Sales' from the FactSales table.
Q4FY16_Sales = 
CALCULATE(SUM(FactSales[Net_Sales]), DATESBETWEEN(tbl_Calendar[Date_Id],  
    DATE(2016,10,1),  
    DATE(2016,12,31)  
  ))

Note:
The DATESBETWEEN function is provided for working with custom date ranges. If you are working with common date intervals such as months, quarters, and years, we recommend that you use the appropriate function, such as DATESINPERIOD.

-------------------------------------------------------------------------------------------------------- 
Thanks, TAMATAM ; Business Intelligence & Analytics Professional 
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog