Forum Discussion

b_t's avatar
b_t
Advocate I
9 years ago

Dynamic target line in line chart

Using the new 'what if' parameter, I was able to create a line chart that displays a line based on the pseudo DAX measure logic:  

measure1  = if  [measure] is < value entered into input parameter ( "target value") then [measure] else blank

 

"target value" measure pseudo DAX :

SELECTEDVALUE([Paramter])

 

When "target value" is added to the 'Value' card (to show target a line) the x-axis is expanded to show all dates in the dataset; whereas without this "target value" line the line chart x-axis is dynamic and only shows dates within the context of the measure1

 

Is there a technique for applying filter context (in this case the dates in an x-axis) to a SELECTEDVALUE([Paramter]) measure?

2 Replies

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft Employee

    Hi b_t,

    I create a sample table as follows based on your description.



    I create a line chart like [measure1] using the formula.

    Measure = IF(SUM(Sales[sale])<Sale[Sale Value],Sale[Sale Value],SUM(Sales[sale]))



    >> When "target value" is added to the 'Value' card (to show target a line) the x-axis is expanded to show all dates in the dataset; whereas without this "target value" line the line chart x-axis is dynamic and only shows dates within the context of the measure1

    I am really confusing about your requirement, could you please share more details based on the sample table, or you can share your sample for further analysis? I upload the .pbix file, please download and review it.

    Best Regards,
    Angelia

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft Employee

    Hi b_t,

    Please follow my solution above, have you resolved your issue? If you have, please mark the right reply as answer, or welcome to share your own workaround.

    Best Regards,
    Angelia