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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Preetish_1
Helper I
Helper I

Dynamic Measures based on filtering

Picture1.png

 

 

 

Hello everyone,

The red target line in the above visual is calculated using the following Measure.

 

Target =

var
FirstDt = FIRSTDATE(T1[C_FullDate].[Date])

var Targ = CALCULATE(
     DIVIDE( SUM(T1[Target %]); COUNTROWS(T1));
     DATESINPERIOD( T1[C_FullDate].[Date]; FirstDt; 12 ; MONTH))

RETURN
Targ

 

1. Is there a way to calculate this target for a period of 6/12 months, and apply it across the entire filtered range? (In the above visual its all 95% as the targets are identical, howerver when they are not equal, the target line varies over the different months, so I would like to be able to calculate a value based on the first or last month, and use the same taget across the entire visual)

 

2. I would also like to know, if there is a way to not hard code 6/12 months into the measure, and if it is possible to make the interval a variable? For example, if we filter the visual for a 9 month range, the target should be calculated for a time period of 9 months and the same target is to be applied for all the 9 months.

 

Any help would be greatly appreciated, as i have been on this for a while and I am unable to figure it out.
Thanks.

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Preetish_1,

 

If I understand you correctly, the formula below should work in your scenario. Smiley Happy

Target =
CALCULATE (
    DIVIDE ( SUM ( T1[Target %] ); COUNTROWS ( T1 ) );
    ALLSELECTED ( T1[C_FullDate] )
)

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Preetish_1,

 

If I understand you correctly, the formula below should work in your scenario. Smiley Happy

Target =
CALCULATE (
    DIVIDE ( SUM ( T1[Target %] ); COUNTROWS ( T1 ) );
    ALLSELECTED ( T1[C_FullDate] )
)

 

Regards

Thanks a lot @v-ljerr-msft , this works perfectly.

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.