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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
SQUILES
Helper I
Helper I

DATE RANGE DYNAMIC

HI...I need help!!

I need to clasified my date column by period (current and prev). Each period is from day 6th to day 5th(next month).

I need just to show the last two period.

Example:

from: 2/5/2020 to: 3/6/2020 = prev_period

from: 3/6/2020 to: 4/5/2020 = current period

In 4/6/2020 change:

from: 3/6/2020 to: 4/5/2020 - prev_period

from: 4/6/2020 to 5/5/2020 - current

 

Any suggest? If need more detail just tell me.

2 ACCEPTED SOLUTIONS

@SQUILES ,

 

I think it needs just an adjustment:

Period =

VAR _startCurrent = EOMONTH(TODAY(); -2) + 6
VAR _endCurrent = EOMONTH(TODAY(); -1) + 5
VAR _startPrevious = EOMONTH(TODAY(); -3) + 6
VAR _endPrevious = EOMONTH(TODAY(); -2) + 5

RETURN
IF('Date'[Date] >= _startCurrent && 'Date'[Date] <= _endCurrent; "Current";
IF('Date'[Date] >= _startPrevious && 'Date'[Date] <= _endPrevious; "Previous"; BLANK()))
 

 

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

@SQUILES ,

 

I just changed the code, try it again:

 

Period =
VAR _startCurrent = EOMONTH(TODAY(); -2) + 6
VAR _endCurrent = EOMONTH(TODAY(); -1) + 5
VAR _startPrevious = EOMONTH(TODAY(); -3) + 6
VAR _endPrevious = EOMONTH(TODAY(); -2) + 5

RETURN
IF('Date'[Date] >= _startCurrent && 'Date'[Date] <= _endCurrent; "Current";
IF('Date'[Date] >= _startPrevious && 'Date'[Date] <= _endPrevious; "Previous"; BLANK()))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

7 REPLIES 7
vanessafvg
Community Champion
Community Champion

can you explain a bit more about how you are using this.   are you wanting a text column called previous period or are you wanting a value for the previous period, some dummy data with an example of what you want to end up with will be really useful.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




I want a text column called period (current or prev) . Today is 3/31/2020, the range is:

prev = 2/6/2020 - 3/5/2020

curr = 3/6/2020 - 4/5/2020 

When date reach 4/6/2020, the new range

prev = 3/6/2020 - 4/5/2020

curr = 4/6/2020 - 5/5/2020

 

sample data 

Hi @SQUILES ,

 

Try this code for calculated column:

 

Period =
VAR _startCurrent = EOMONTH(TODAY(); -1) + 6
VAR _endCurrent = EOMONTH(TODAY(); 0) + 5
VAR _startPrevious = EOMONTH(TODAY(); -2) + 6
VAR _endPrevious = EOMONTH(TODAY(); -1) + 5

RETURN
IF('Date'[Date] >= _startCurrent && 'Date'[Date] <= _endCurrent; "Current";
IF('Date'[Date] >= _startPrevious && 'Date'[Date] <= _endPrevious; "Previous"; BLANK()))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thanks @camargos88,

 

i try something like that using today(), but give me a prev period 4/1/2020 when supose to give me current period.

Current period runs from 3/6/2020 to 4/5/2020.

@SQUILES ,

 

I think it needs just an adjustment:

Period =

VAR _startCurrent = EOMONTH(TODAY(); -2) + 6
VAR _endCurrent = EOMONTH(TODAY(); -1) + 5
VAR _startPrevious = EOMONTH(TODAY(); -3) + 6
VAR _endPrevious = EOMONTH(TODAY(); -2) + 5

RETURN
IF('Date'[Date] >= _startCurrent && 'Date'[Date] <= _endCurrent; "Current";
IF('Date'[Date] >= _startPrevious && 'Date'[Date] <= _endPrevious; "Previous"; BLANK()))
 

 

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88 , is work, but i think i can't use today(), to calculated the range, beacuse today()=4/1/2020, and 4/1/2020 is supose to be in current period (current 3/6/2020 - 4/5/2020). 

@SQUILES ,

 

I just changed the code, try it again:

 

Period =
VAR _startCurrent = EOMONTH(TODAY(); -2) + 6
VAR _endCurrent = EOMONTH(TODAY(); -1) + 5
VAR _startPrevious = EOMONTH(TODAY(); -3) + 6
VAR _endPrevious = EOMONTH(TODAY(); -2) + 5

RETURN
IF('Date'[Date] >= _startCurrent && 'Date'[Date] <= _endCurrent; "Current";
IF('Date'[Date] >= _startPrevious && 'Date'[Date] <= _endPrevious; "Previous"; BLANK()))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.