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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Evelin_
Regular Visitor

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_
Regular Visitor

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

 

Evelin_
Regular Visitor

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!

 

 

v-kongfanf-msft
Community Support
Community Support

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.