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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pippo80
New Member

Naming specific dates for filtering afterwards

Hi there,

 

I  would ike to creat a column naming specific date ranges in order to create a filter afterwards. Right now I have set up the follwing IF-statement but it is rather a long formula, specifically if I want to add more weekly periods afterwards:

 

Date Range = IF('[DimDate] = DATE(2017;06;22);"22.-28.06";IF(''[DimDate] = DATE(2017;06;23);"22.-28.06";IF('[DimDate] = DATE(2017;06;24);"22.-28.06";IF('[DimDate] = DATE(2017;06;25);"22.-28.06";IF('[DimDate] = DATE(2017;06;26);"22.-28.06";IF('[DimDate] = DATE(2017;06;27);"22.-28.06";IF('[DimDate] = DATE(2017;06;28);"22.-28.06";"")))))))

 

Is there a way of doing it in a 'smarter' way? I am quite new to DAX...

 

Thanks

P

2 ACCEPTED SOLUTIONS
pmhoang94
Helper I
Helper I

Hi @pippo80,

I can use measure:

Date Range = IF([DimDate] >= DATE(2017;06;22) && [DimDate] <= DATE(2017;06;28);"22.-28.06";"")))))))

View solution in original post

v-ljerr-msft
Employee
Employee

Hi @pippo80,

 

You can also use the SWITCH function to add a date range column to you table in this scenario. The formula below is for your reference. Smiley Happy

Date Range =
SWITCH (
    TRUE ();
    [DimDate] >= DATE ( 2017; 07; 22 ) && [DimDate] <= DATE ( 2017; 07; 25 ); "22.-28.07"; // Just need add a new condition row to add more weekly periods
    [DimDate] >= DATE ( 2017; 06; 22 ) && [DimDate] <= DATE ( 2017; 06; 28 ); "22.-28.06";
    "others"
)

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @pippo80,

 

You can also use the SWITCH function to add a date range column to you table in this scenario. The formula below is for your reference. Smiley Happy

Date Range =
SWITCH (
    TRUE ();
    [DimDate] >= DATE ( 2017; 07; 22 ) && [DimDate] <= DATE ( 2017; 07; 25 ); "22.-28.07"; // Just need add a new condition row to add more weekly periods
    [DimDate] >= DATE ( 2017; 06; 22 ) && [DimDate] <= DATE ( 2017; 06; 28 ); "22.-28.06";
    "others"
)

 

Regards

pmhoang94
Helper I
Helper I

Hi @pippo80,

I can use measure:

Date Range = IF([DimDate] >= DATE(2017;06;22) && [DimDate] <= DATE(2017;06;28);"22.-28.06";"")))))))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.