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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Add target line for each filter in slicer

Hi all,

 

Want to ask for below chart. For chart A, I add a constant line for overall machine target (79.5%)

But when I choose certain machine (eg: 310 EA Machine) the target should be different, but as you can see below the constant line remain (79.5%) which is wrong. 

 

Chart A

nuhasan_1-1656055387589.png

 

Chart B

nuhasan_2-1656055459865.png

 

I know constant line are no possible for my solution. Do you have suggestion how can I do a target line based on each machine (filter).

 

Regards,

Nuha

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1656469144632.png

Here are the steps you can follow:

1. Create calculated table.

Slicer_Machine =
DISTINCT('Table'[Machine])

vyangliumsft_1-1656469144633.png

Slicer_Yearmonth =
DISTINCT('Table'[Year & Month])

vyangliumsft_6-1656469188804.png

2. Create measure.

select_value =
var _year=SELECTEDVALUE('Slicer_Yearmonth'[Year & Month])
var _group=SELECTEDVALUE('Slicer_Machine'[Machine])
var _month=CALCULATE(MAX('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Year & Month]=_year))
return
DIVIDE(
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date].[Month]=_month&&'Table'[Machine]=_group)),
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date].[Month]=_month)))
month_amount =
var _year=SELECTEDVALUE('Slicer_Yearmonth'[Year & Month])
var _group=SELECTEDVALUE('Slicer_Machine'[Machine])
var _month=CALCULATE(MAX('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Year & Month]=_year))
return
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date].[Month]=_month)
)
Flag =
var _year=SELECTEDVALUE('Slicer_Yearmonth'[Year & Month])
var _group=SELECTEDVALUE('Slicer_Machine'[Machine])
var _month=CALCULATE(MAX('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Year & Month]=_year))
return
IF(
    FORMAT(MAX('Table'[Date]),"mmmm")=_month,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_3-1656469144634.png

4. Result:

Machine == A

vyangliumsft_4-1656469144638.png

 

Machine == B

vyangliumsft_5-1656469144641.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1656469144632.png

Here are the steps you can follow:

1. Create calculated table.

Slicer_Machine =
DISTINCT('Table'[Machine])

vyangliumsft_1-1656469144633.png

Slicer_Yearmonth =
DISTINCT('Table'[Year & Month])

vyangliumsft_6-1656469188804.png

2. Create measure.

select_value =
var _year=SELECTEDVALUE('Slicer_Yearmonth'[Year & Month])
var _group=SELECTEDVALUE('Slicer_Machine'[Machine])
var _month=CALCULATE(MAX('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Year & Month]=_year))
return
DIVIDE(
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date].[Month]=_month&&'Table'[Machine]=_group)),
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date].[Month]=_month)))
month_amount =
var _year=SELECTEDVALUE('Slicer_Yearmonth'[Year & Month])
var _group=SELECTEDVALUE('Slicer_Machine'[Machine])
var _month=CALCULATE(MAX('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Year & Month]=_year))
return
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date].[Month]=_month)
)
Flag =
var _year=SELECTEDVALUE('Slicer_Yearmonth'[Year & Month])
var _group=SELECTEDVALUE('Slicer_Machine'[Machine])
var _month=CALCULATE(MAX('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Year & Month]=_year))
return
IF(
    FORMAT(MAX('Table'[Date]),"mmmm")=_month,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_3-1656469144634.png

4. Result:

Machine == A

vyangliumsft_4-1656469144638.png

 

Machine == B

vyangliumsft_5-1656469144641.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Ashish_Mathur
Super User
Super User

Hi,

How should the target be calculated?  What is the logic of that calculation?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @Ashish_Mathur ,

 

There is no calculaton for target. We just input the target based on virtual discussion.

 

For example,

 

MachineTargetResult for May22 (202205)
310 EA Machine94.6%80.99%

 

Regards,

Nuha

amitchandak
Super User
Super User

@Anonymous , Then you need to create a measure and use that as a constant line or create a clustered bar visual

 

Switch (true() ,

not(isfiltered(Table[Machine])) , 79.5 ,

max(Table[Machine]) = "310 EA Machine", 70.0

)

 

Add others as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

For clustered bar visual, how to combine stacked column chart with line chart?

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors