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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
msommerf
Helper III
Helper III

Date Slicer - Custom Phases

Hi,

I have a date table which defines the phases of a project every year as follows:

 

Phase 1 = 1st January - 31st July

Phase 2 = 1st August - 31st December

 

I have created a column in my date table to work out and display the Current Phase so this can be used in a slicer using:

 

Phase Selection =
var phase_today = CALCULATE(max('Dates'[Phase Year]) ,'Dates'[Date] = TODAY())
return IF([Phase Year] = phase_today, "Current Phase", Dates[Phase Year])
 
Can anyone help me dynamically display the Previous Phase?
 
So if the current phase = 2020 Phase 1, the previous phase would be 2019 Phase 2
if the current phase = 2019 Phase 2, the previous phase would be 2019 Phase 1 etc...
 
Date Table.jpg
Any assistance appreciated.
1 ACCEPTED SOLUTION

HI  @msommerf 

Ok, try this way:

previous phase = 
var _current= CALCULATE(MAX(Dates[Phase Year]),FILTER(Dates,Dates[Phase Selection]="Current Phase")) return
IF(IF(RIGHT(_current,1)="2",LEFT(_current,4)&" Phase 1",VALUE(LEFT(_current,4))-1&" Phase 2")=Dates[Phase Year],"Previous Phase",Dates[Phase Year])

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi  @msommerf 

Just create a column as below:

previous phase = IF(RIGHT(Dates[Phase Year],1)="2",LEFT(Dates[Phase Year],4)&" Phase 1",VALUE(LEFT(Dates[Phase Year],4))-1&" Phase 2")

 

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi @v-lili6-msft 

 

Many thanks for your response.

 

Your solution works in that it is displaying the previous Phase Year.

I was looking for the column to display the words "Previous Phase" in this column and not display the phase year value.

 

Date Table 2.jpg

HI  @msommerf 

Ok, try this way:

previous phase = 
var _current= CALCULATE(MAX(Dates[Phase Year]),FILTER(Dates,Dates[Phase Selection]="Current Phase")) return
IF(IF(RIGHT(_current,1)="2",LEFT(_current,4)&" Phase 1",VALUE(LEFT(_current,4))-1&" Phase 2")=Dates[Phase Year],"Previous Phase",Dates[Phase Year])

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lili6-msft 

This is perfect!

Many thanks for a quick response 🙂

Pragati11
Super User
Super User

Hi @msommerf ,

 

Create a caluclated column as follows:

 

Previous = CONCATENATE(LEFT(SUBSTITUTE(phase[Current]," ","-"),SEARCH("-",SUBSTITUTE(phase[Current]," ","-"))-1), CONCATENATE(" ", (RIGHT(SUBSTITUTE(phase[Current]," ","-"),LEN(SUBSTITUTE(phase[Current]," ","-"))-SEARCH("-",SUBSTITUTE(phase[Current]," ","-"))) - 1)))
 
Replace  phase[Current] in above DAX with your table-name and phase-year column.
 
Thanks,
Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Thank you for your quick response.

I have created a calculated column using your DAX formula as follows:

 

Previous Phase = CONCATENATE(LEFT(SUBSTITUTE(Dates[Phase Year]," ","-"),SEARCH("-",SUBSTITUTE(Dates[Phase Year]," ","-"))-1),
CONCATENATE(" ", (RIGHT(SUBSTITUTE(Dates[Phase Year]," ","-"),LEN(SUBSTITUTE(Dates[Phase Year]," ","-"))
-SEARCH("-",SUBSTITUTE(Dates[Phase Year]," ","-"))) - 1)))
 
But I get the following error:
 
"Cannot convert value 'Phase-1' of type text to number"
Date Table.jpg

 Regards

Mark.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.