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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
Redraidas1
Helper I
Helper I

Issue with Switch statement

Does anybody know why I'm getting this error message for the below SWITCH statement and how to make it work? Thanks!

Error: 'The expression specified in the query is not a valid table expression'



Measure =

SWITCH (
TRUE(),
'Conversion Rates v2'[M_Conversion] = 1, GENERATESERIES(0, 10000, 10),
'Conversion Rates v2'[M_Conversion] <1, GENERATESERIES(0, 100000, 100),
'Conversion Rates v2'[M_Conversion] <0.1, GENERATESERIES(0, 1000000, 1000),
'Conversion Rates v2'[M_Conversion] <0.001, GENERATESERIES(0, 10000000, 10000)
)
1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Redraidas1 ,

 

First create a table as below:

Table = GENERATESERIES(0, 10000000, 10)

Then create a measure as below:

measure = 
SWITCH (
TRUE(),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion]) <0.001, 
IF(MOD(MAX('Table'[Value]),10000)=0&&MAX('Table'[Value])<=10000000,MAX('Table'[Value]),BLANK()),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion]) <0.1, 
IF(MOD(MAX('Table'[Value]),1000)=0&&MAX('Table'[Value])<=1000000,MAX('Table'[Value]),BLANK()),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion])<1,
IF(MOD(MAX('Table'[Value]),100)=0&&MAX('Table'[Value])<=100000,MAX('Table'[Value]),BLANK()),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion])=1,
IF(MOD(MAX('Table'[Value]),10)=0&&MAX('Table'[Value])<=10000,MAX('Table'[Value]),BLANK()))

Put the measure in the filter field>choose "is not blank":

v-kelly-msft_0-1607307464820.png

 

And you will see:

v-kelly-msft_1-1607307481660.pngv-kelly-msft_2-1607307491547.png

 

For my sample .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi @Redraidas1 ,

 

First create a table as below:

Table = GENERATESERIES(0, 10000000, 10)

Then create a measure as below:

measure = 
SWITCH (
TRUE(),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion]) <0.001, 
IF(MOD(MAX('Table'[Value]),10000)=0&&MAX('Table'[Value])<=10000000,MAX('Table'[Value]),BLANK()),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion]) <0.1, 
IF(MOD(MAX('Table'[Value]),1000)=0&&MAX('Table'[Value])<=1000000,MAX('Table'[Value]),BLANK()),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion])<1,
IF(MOD(MAX('Table'[Value]),100)=0&&MAX('Table'[Value])<=100000,MAX('Table'[Value]),BLANK()),
SELECTEDVALUE('Conversion Rates v2'[M_Conversion])=1,
IF(MOD(MAX('Table'[Value]),10)=0&&MAX('Table'[Value])<=10000,MAX('Table'[Value]),BLANK()))

Put the measure in the filter field>choose "is not blank":

v-kelly-msft_0-1607307464820.png

 

And you will see:

v-kelly-msft_1-1607307481660.pngv-kelly-msft_2-1607307491547.png

 

For my sample .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

AlB
Community Champion
Community Champion

@Redraidas1 

Can you share the pbix?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

AlB
Community Champion
Community Champion

Hi @Redraidas1 

Remember you have no row context if you are using this in a visual. Depending on your filter context, you'll need something like:

Measure =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Conversion Rates v2'[M_Conversion] ) = 1, GENERATESERIES ( 0, 10000, 10 ),
    SELECTEDVALUE ( 'Conversion Rates v2'[M_Conversion] ) < 1, GENERATESERIES ( 0, 100000, 100 ),
    etc.
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Just changed it as per you suggestion - unfortunately still getting the same error. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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