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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sparkline on switch measure "undefined"

Hey PowerBees

 

I'm working on a BSC-solution and I want to add a sparkline. The solution uses direct query from many separate datamodels, which in turn pull data from our GxP server. The BSC shows >100 KPIs from different areas of the business. They are listed in Time Intelligence columns, to show Last Closed Month, Year to Closed Month, Last 12 Closed Months and a sparkline for the Last 12 Closed Months.

The KPIs are calculated by separate measures and combined with a single switch measure, like so:
_ExampleSelector =

VAR vSelectedMeasure = SELECTEDVALUE('KPIlist'[KPI],"NONE")

VAR vMeasureToDisplay = SWITCH( vSelectedMeasure

,"ExampleKPI1", [ExampleMeasure1]

//,"ExampleKPI2", [ExampleMeasure2]

//,"ExampleKPI3", [ExampleMeasure3]

,BLANK())

RETURN vMeasureToDisplay

 

Using the above I get no sparkline graph and the hover says "undefined".

If I use the individual measures the sparkline works fine, so I believe the problem is isolated to the measure linked above.
Do you have any tips I can try to fix this?

 
2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Can define a default measure when nothing is selected

 

_ExampleSelector =

VAR vSelectedMeasure = SELECTEDVALUE('KPIlist'[KPI],"ExampleKPI1")

VAR vMeasureToDisplay = SWITCH( vSelectedMeasure

,"ExampleKPI1", [ExampleMeasure1]

//,"ExampleKPI2", [ExampleMeasure2]

//,"ExampleKPI3", [ExampleMeasure3]

,[ExampleMeasure1])

RETURN vMeasureToDisplay

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks, This worked for me in a similar scenario!!

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.