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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nuhasan
Helper IV
Helper IV

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
v-yangliu-msft
Community Support
Community Support

Hi  @nuhasan ,

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
v-yangliu-msft
Community Support
Community Support

Hi  @nuhasan ,

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/

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

@nuhasan , 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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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