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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Evelin_
Helper I
Helper I

Power BI multiple target lines by filtering with slicer + differences on the column

Hello,

I would like to create a chart where actuals are columns/months and target can be selected with slicer and it changes dynamically. Even more if possible, I would like to add the %diff on top of the columns vs the selected target. I did the chart against 1 target, but I can not develop it further with more targets. I show you 1 column example where target is the grey short line and the figures are calculated with dax.

 image.png

Is it possible to have 3 different targets in 1 chart and after selecting one by slicer, the differences will appear? I dont want to have 3 targets on the chart at the same time.

Maybe my table does it a little bit harder, as I have 1 database where there is 1 column with the version, meaning actual, BP, PY, everything is in 1 column. See a dummy version:

Evelin__0-1730904874425.png

 

Thank you in advance for the help!

1 ACCEPTED SOLUTION
Sahir_Maharaj
Super User
Super User

Hello @Evelin_,

 

Can you please try the following:

Actual_vs_Target_Display = 
VAR SelectedTarget = SELECTEDVALUE('Table'[Version]) -- Get the selected target from the slicer
VAR ActualSales = 
    CALCULATE(
        SUM('Table'[Sales]),
        'Table'[Version] = "ACT"
    )
VAR TargetSales = 
    CALCULATE(
        SUM('Table'[Sales]),
        'Table'[Version] = SelectedTarget
    )
VAR SalesDifference = ActualSales - TargetSales
VAR PercentDifference = 
    IF(
        TargetSales <> 0,
        DIVIDE(SalesDifference, TargetSales, 0),
        BLANK()
    )
RETURN
    IF(
        NOT(ISBLANK(ActualSales)),
        ActualSales & " (Target: " & TargetSales & ", Diff: " & FORMAT(PercentDifference, "0.00%") & ")",
        BLANK()
    )

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

4 REPLIES 4
Evelin_
Helper I
Helper I

I did it, Thank you for your help! it was very useful to finish my chart 🙂

 

Evelin_
Helper I
Helper I

Hello Sahir, 

Thank you for the dax, with your help I created this measure succesfully in my PowerBI. Only question left is how I add it on the chart and connect it with the slicer? So far I had the posting period in X axis, actual sales column y axis, and 1 target line on line y axis, and this is what I want to change based on slicer + the value label.

Thank you very much!

 

 

Anonymous
Not applicable

Hi @Evelin_ ,

 

Did Sahir_Maharaj reply solve your problem? If so, please mark it as the correct solution, and point out if the problem persists.

 

Best regards,

Adamk Kong

Sahir_Maharaj
Super User
Super User

Hello @Evelin_,

 

Can you please try the following:

Actual_vs_Target_Display = 
VAR SelectedTarget = SELECTEDVALUE('Table'[Version]) -- Get the selected target from the slicer
VAR ActualSales = 
    CALCULATE(
        SUM('Table'[Sales]),
        'Table'[Version] = "ACT"
    )
VAR TargetSales = 
    CALCULATE(
        SUM('Table'[Sales]),
        'Table'[Version] = SelectedTarget
    )
VAR SalesDifference = ActualSales - TargetSales
VAR PercentDifference = 
    IF(
        TargetSales <> 0,
        DIVIDE(SalesDifference, TargetSales, 0),
        BLANK()
    )
RETURN
    IF(
        NOT(ISBLANK(ActualSales)),
        ActualSales & " (Target: " & TargetSales & ", Diff: " & FORMAT(PercentDifference, "0.00%") & ")",
        BLANK()
    )

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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