Forum Discussion

mmcanelly's avatar
mmcanelly
Helper II
2 years ago
Solved

Sparkline for Dynamic Measure

I have a table of dynamic measures where I want to add a sparkline for each. The table looks something like this:

 

Metric NameValue
Metric 1$150,000
Metric 24.5%
Metric 36.0%

 

The "Value" column is a measure set up as follows:

 

Metric Value = 
VAR SelectedMetric = SELECTEDVALUE ('Dynamic Metrics'[Metric Name])
RETURN
SWITCH (
    SelectedMetric,
    "Metric 1", [Metric 1 MTD Value],
    "Metric 2", [Metric 2 MTD Value],
    "Metric 3", [Metric 3 MTD Value]
)

 

 

I want to add a sparkline for each of the rows in the table showing weekly values. I've been able to set up individual measures for each sparkline that work when I test them on their own, but as soon as I add them to a dynamic measure setup similar to the formula above where I'm selecting the measure based on SELECTEDVALUE('Dynamic Metrics'[Metric Name]), they no longer work and the sparklines show up as blank.

 

Is there a way to handle this where I can show the sparkline for a separate measure in each row?

  • Hi mmcanelly 

    Please update the formula to :

    Metric Total2 =
    VAR SelectedMetric = SELECTEDVALUE (Metrics[Metric Name])
    RETURN
    if (ISBLANK(SelectedMetric),"",
    SWITCH(SelectedMetric,
    "Def $",[Total Def $],
    "CCIR",[CCIR],
    "QER",[QER]))
    Result :

    Modified pbix is attached

    If this post helps, then please consider Accepting it as the solution to help the other

    members find it more quickly

4 Replies

    • Ritaf1983's avatar
      Ritaf1983
      Super User

      Hi mmcanelly 

      Please update the formula to :

      Metric Total2 =
      VAR SelectedMetric = SELECTEDVALUE (Metrics[Metric Name])
      RETURN
      if (ISBLANK(SelectedMetric),"",
      SWITCH(SelectedMetric,
      "Def $",[Total Def $],
      "CCIR",[CCIR],
      "QER",[QER]))
      Result :

      Modified pbix is attached

      If this post helps, then please consider Accepting it as the solution to help the other

      members find it more quickly

      • mmcanelly's avatar
        mmcanelly
        Helper II

        Thank you Ritaf1983!! This fixed the issue. Any idea why adding the if-isblank logic fixes this? I would think the original formula should give the same result, but obviously it's not.