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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
admin11
Memorable Member
Memorable Member

How to combine 2 date expression into 1 ?

Hi All

 

My Date have 2 different expression :-

 

Expression 1 :-

DATE =
CALENDAR(Date(2003,01,01),date(2021,12,31))
 
Expression 2 :- 
DATE =
CALENDAR ( "2003,1,1", TODAY() )
 
May i know how to combine above 2 expression into ? Some thing look like below :-
 
DATE =
1=CALENDAR(Date(2003,01,01),date(2021,12,31))
2=CALENDAR ( "2003,1,1", TODAY() )
 
So that i can use Slicer to switch for expression 1 or 2
 
 
Paul 
 
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @admin11 

Just as amitchandak said, that's not available. But you can use measure to select any Calendar table you want, for example,

when you select Date1, then measure will do calculations by using table Date1, and if you select Date2, then the measure will do calculations by using table Date2.

vxiaotang_0-1642670091808.pngvxiaotang_1-1642670115564.png

Measure = 
    var _Date= SELECTEDVALUE(Slicer[Column1])
    var _CalculationForDate1= CALCULATE(MAX(DATE1[Date]),ALL(DATE1))
    var _CalculationForDate2= CALCULATE(MAX(DATE2[Date]),ALL(DATE2))
return 
    IF(_Date="Date1",_CalculationForDate1,IF(_Date="Date2",_CalculationForDate2))

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @admin11 

Just as amitchandak said, that's not available. But you can use measure to select any Calendar table you want, for example,

when you select Date1, then measure will do calculations by using table Date1, and if you select Date2, then the measure will do calculations by using table Date2.

vxiaotang_0-1642670091808.pngvxiaotang_1-1642670115564.png

Measure = 
    var _Date= SELECTEDVALUE(Slicer[Column1])
    var _CalculationForDate1= CALCULATE(MAX(DATE1[Date]),ALL(DATE1))
    var _CalculationForDate2= CALCULATE(MAX(DATE2[Date]),ALL(DATE2))
return 
    IF(_Date="Date1",_CalculationForDate1,IF(_Date="Date2",_CalculationForDate2))

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

@v-xiaotang 

 

Thank you very much , microsoft have many expert.

 

Paul

amitchandak
Super User
Super User

@admin11 , I think you can not. You can add additional flag column

 

Addcolumns( CALENDAR ( Date(2003,01,01), TODAY() ) , "Flag", if([Date]>= Date(2003,01,01) && [Date]<= date(2021,12,31) , 1,0))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

I get error msg below :-

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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