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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
bourne2000
Helper V
Helper V

How to make fornight calculation in date table?

Hi

 

I have a date table, and would like to calculate fornight

 

Expected output

 

DateFornight
1/01/2022Jan 1 - 15
2/01/2022Jan 1 - 15
3/01/2022Jan 1 - 15
4/01/2022Jan 1 - 15
5/01/2022Jan 1 - 15
6/01/2022Jan 1 - 15
7/01/2022Jan 1 - 15
8/01/2022Jan 1 - 15
9/01/2022Jan 1 - 15
10/01/2022Jan 1 - 15
11/01/2022Jan 1 - 15
12/01/2022Jan 1 - 15
13/01/2022Jan 1 - 15
14/01/2022Jan 1 - 15
15/01/2022Jan 1 - 15
16/01/2022Jan 16 - 31
17/01/2022Jan 16 - 31
18/01/2022Jan 16 - 31
19/01/2022Jan 16 - 31
20/01/2022Jan 16 - 31
21/01/2022Jan 16 - 31
22/01/2022Jan 16 - 31
23/01/2022Jan 16 - 31
24/01/2022Jan 16 - 31
25/01/2022Jan 16 - 31
26/01/2022Jan 16 - 31
27/01/2022Jan 16 - 31
28/01/2022Jan 16 - 31
29/01/2022Jan 16 - 31
30/01/2022Jan 16 - 31
31/01/2022Jan 16 - 31
1/02/2022Feb 1 - 15
2/02/2022Feb 1 - 15
3/02/2022Feb 1 - 15
4/02/2022Feb 1 - 15
5/02/2022Feb 1 - 15
6/02/2022Feb 1 - 15
7/02/2022Feb 1 - 15
8/02/2022Feb 1 - 15
9/02/2022Feb 1 - 15
10/02/2022Feb 1 - 15
11/02/2022Feb 1 - 15
12/02/2022Feb 1 - 15
13/02/2022Feb 1 - 15
14/02/2022Feb 1 - 15
15/02/2022Feb 1 - 15
16/02/2022Feb 2 - 28
17/02/2022Feb 2 - 28
18/02/2022Feb 2 - 28
19/02/2022Feb 2 - 28
20/02/2022Feb 2 - 28
21/02/2022Feb 2 - 28
22/02/2022Feb 2 - 28
23/02/2022Feb 2 - 28
24/02/2022Feb 2 - 28
25/02/2022Feb 2 - 28
26/02/2022Feb 2 - 28
27/02/2022Feb 2 - 28
28/02/2022Feb 2 - 28
1/03/2022Mar 1 - 15

 

I have day number in my date table and used below dax to create a new column 

 

 

fortnight = IF( Date[DayNo] <= 15, "Fortnight-1", "Fornight-2")

 

 

The above dax works to seperate the fornights. However, I am not able to get the above output like Jan 1-15, Jan 16-31 etc

 

Can anyone advise how to do this? I created date table using M query

 

 

1 ACCEPTED SOLUTION
kunal15sep
Frequent Visitor

fortnight =
var lastdayinMonth= ENDOFMONTH('Date'[Date])


return
if(DAY([Date])<=15, 'Date'[Month] & " 1-15",'Date'[Month]& " 16-" & day(lastdayinMonth))

View solution in original post

2 REPLIES 2
kunal15sep
Frequent Visitor

Using "Month" as a sepearate column FORMAT([Date],"mmm")
kunal15sep
Frequent Visitor

fortnight =
var lastdayinMonth= ENDOFMONTH('Date'[Date])


return
if(DAY([Date])<=15, 'Date'[Month] & " 1-15",'Date'[Month]& " 16-" & day(lastdayinMonth))

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.