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
Jeanxyz
Power Participant
Power Participant

switch()

I'm trying to write a switch function with multiple conditions in the <value> part (selectedvalue(Fact_Forecast[Version])="LE02" && maxdate>=date([CurrentYear],5,1)), it looks this won't work in a Switch() function. How can I solve the problem without using embedded if function?

 

Forecast Amount_Mgmt PL View (EUR) YTD_2 =
var maxdate=max(dim_date[Date])
var amt=Switch(true(),
selectedvalue(Fact_Forecast[Version]) in {"LE00","LE01"},[Forecast Amount_Mgmt PL View (EUR)],
selectedvalue(Fact_Forecast[Version])="LE02" && maxdate>=date([CurrentYear],5,1)
calculate([Reporting Amount_Mgmt PL View],datesbetween(Dim_Date[Date],date([CurrentYear],1,1),date([CurrentYear],4,30))) +calculate([Forecast Amount_Mgmt PL View (EUR)],datesbetween(Dim_Date[Date],date([CurrentYear],5,1),maxdate)
)),

selectedvalue(Fact_Forecast[Version])="LE03",
calculate([Reporting Amount_Mgmt PL View],datesbetween(dim_date[Date],date([CurrentYear],1,1), date([CurrentYear],7,31))) + calculate([Forecast Amount_Mgmt PL View (EUR)],datesbetween(Dim_Date[Date],date([CurrentYear],8,1),date([CurrentYear],12,31)
)))
Return
amt
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Jeanxyz 

I‘ve create a sample and the measure with similar logic works OK.

vxiaotang_0-1626075819986.png

if problem sitll persists, could you share your PBI file after removing sensitive information?

 

 

 

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

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @Jeanxyz 

Have you solved your problem? If yes, kindly accept the answer helpful as the solution. so the others can find it more quickly.

Or

if problem still persists, please let me know.

 

 

Best Regards,

Community Support Team _ Tang

v-xiaotang
Community Support
Community Support

Hi @Jeanxyz 

I‘ve create a sample and the measure with similar logic works OK.

vxiaotang_0-1626075819986.png

if problem sitll persists, could you share your PBI file after removing sensitive information?

 

 

 

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.

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 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.

Top Solution Authors