Forum Discussion
Sparkline in matrix table
Hi All,
Have you ever encountered issues generating sparklines in a Matrix visual?
I would like to display the "Selected KPI" value by month in a structure similar to the example below.
The issue is that the [Selected_KPI] measure is dynamic and retrieves values from multiple different source tables connected through relationships. The measure always returns a numeric value — for example, percentage KPIs are returned as decimals (e.g. 0.98 instead of 98%), so I believe the data type/format should not be the issue.
I also do not think the Date table is the problem. I created a simplified test example using the same Year-Month field from my 'Date' table, and the sparkline works correctly when the metric comes from a single source table.
However, when using the dynamic [Selected_KPI] measure based on multiple sources and a SWITCH statement, the sparkline does not render properly in the Matrix visual.
Has anyone experienced a similar issue or knows what could be causing this?
Any advice would be greatly appreciated.
5 Replies
- Shai_Karmani
Super User
Hey! Yeah I've run into this one.
The sparkline works by grouping your measure by that Year-Month field. A single-source measure works because that table is related to the Date table, so it varies month to month. Your dynamic SWITCH measure spans multiple source tables, and the line only renders for branches whose source table actually propagates filters from the same Date table you put on the sparkline axis.
So any KPI whose source table has no active relationship to that Date table (or only an inactive one) returns a flat or blank value across months, and there's nothing for the sparkline to draw.
Quick things to check:
- Does every table feeding the SWITCH have an active relationship to the exact Date table on the sparkline axis?
- For the ones using inactive relationships, wrap the branch in CALCULATE with USERELATIONSHIP.
- Test by dropping the raw Year-Month + [Selected_KPI] into a plain table visual. If the value doesn't change by month there, the sparkline can't render it either.That last test usually tells you instantly which branch is the culprit.
If this helped, a thumbs up and accepting the solution would be appreciated.
Best,
Shai Karmani - danextian
Super User
The sparkline should still work even if the measures in the SWITCH statement are coming from different tables unless, as Shai_Karmani have mentioned, those other measures do not have an active relationship to the Dates table used in creating a sparkline. If this isn't the case it would be worthwhile to share a sample copy of the pbix with confidential data removed/dummified data.
- AnonymousNot applicable
Hi ALZK
Thank you for reaching out to the Microsoft Fabric Forum Community.
Shai_Karmani danextian Thanks for the inputs.
I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.
- ALZK
Advocate I
Thank you for all answers.
Regarding potential issue causes, I reduced the number of switch metrics to 3 to ensure proper testing. I also made sure all of them have an active relationship and checked Selected_KPI in the table — it correctly shows data for the particular months. However, the sparkline still does not generate.- AnonymousNot applicable
Hi ALZK
Thank you for reaching out to the Microsoft Fabric Forum Community.
Information provided by users was helpful.
Since Selected_KPI is showing the correct values for each month and all the tables have active relationships, it doesn't look like a modeling or date-filtering issue. Given that the sparkline still doesn't render even after simplifying the SWITCH logic, this may be related to how Matrix sparklines handle dynamic measures. As a quick test, can you please try creating a sparkline using one of the individual KPI measures instead of the dynamic SWITCH measure. If that works, it would help narrow down the cause. If the issue continues, In this case please reach out to support team to help on this. Kindly raise a support ticker here How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn.
If there are any deviations from your expectation please let us know we are happy to address.
Thanks.