cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

var + return multiple

hello 

 

can someone help me please 

i'm woindering if it's possible to have in a return clause multiple lignes 
here is the code that i'm wrinting

 

Colonne_tes =
var __tisDate = 'DimDate'[FullDateAlternateKey]
var __lastDateinTable = MAX(DimDate[FullDateAlternateKey])
var __DaybeforToday = __lastDateinTable - 1
return
IF(
1 * (__tisDate = __lastDateinTable),
2 *(__lastDateinTable = __DaybeforToday)

)
 
the If return nothing, 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: var + return multiple

Hi @rayloubayi 

 

if are you looking to pass multiple logical tests, then you can use SWITCH 

columns =
SWITCH(
    TRUE(),
    'Product'[Color] = "Red", 1,
    'Product'[Color] = "Blue", 2,
    'Product'[Color] = "Black", 4,
    3 --else 
)

 

btw, your question is DAX related did you wanted to recreate it in Power Query?

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

2 REPLIES 2
Highlighted
Super User IV
Super User IV

Re: var + return multiple

Hi @rayloubayi 

 

if are you looking to pass multiple logical tests, then you can use SWITCH 

columns =
SWITCH(
    TRUE(),
    'Product'[Color] = "Red", 1,
    'Product'[Color] = "Blue", 2,
    'Product'[Color] = "Black", 4,
    3 --else 
)

 

btw, your question is DAX related did you wanted to recreate it in Power Query?

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

Highlighted
Helper I
Helper I

Re: var + return multiple

hello using @Mariusz  Answer here is the solution may be it will help somebody 

Colonne_11 =
var __tisDate = 'DimDate'[FullDateAlternateKey]
var __lastDateinTable = MAX(DimDate[FullDateAlternateKey])
var __DaybeforToday = __lastDateinTable - 1
var __Daybeforyesterday = __DaybeforToday - 1
return
SWITCH(
TRUE(),
__tisDate = __lastDateinTable, 1,
__tisDate = __DaybeforToday,2,
__tisDate = __Daybeforyesterday,3,
4
)
 
 
this gives you 
05/03/2020 1
04/03/2020 2
03/03/2020 3
02/03/2020 4
01/03/2020 4

thanks to @Mariusz  for the help 🙂

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021