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

Previous Value from slicer selection

Hi, 

 

Wondering if anyone can help me on this one:

 

I have the following simple measure: 

Total = COUNTROWS('Fleet (Cars)')

In another table we have the labels for year ranges such as:

 

 

RangeIndex
2017-20181
2018-20192

 

When the user clicks the slicer, it shows the number of rows for that period, but I could also like to automatically show the previous period. I have tried with things like the following but to no avail.

 

Previous = CALCULATE(COUNTROWS('Fleet (Cars)');'Ranges'[Index]-1)

Any suggestions how I could achieve this?

 

Many thanks, 

 

Matt

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi again, 

 

Just to let you know we've managed to figure it out with the following:

 

var a = CALCULATE(Max('Ranges'[Index])-1)
var b = CALCULATE(
DISTINCTCOUNT('Fleet (Cars)'[id]);
filter(
ALL('Fleet (Cars)');true());'Ranges'[Index]=a;) return b

Regards, 

 

Matt

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

Give this a shot

 

Previous =
CALCULATE (
    COUNTROWS ( 'Fleet (Cars)' ),
    FILTER (
        ALL ( 'Ranges'[Index] ),
        'Ranges'[Index]
            = SELECTEDVALUE ( 'Ranges'[Index] ) - 1
    )
)
Anonymous
Not applicable

Thanks @Zubair_Muhammad but getting a multiple column error on this one:

 

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

 

Hi @Anonymous

 

Could you show me a screen shot? or share the file?

How are the tables related?

Anonymous
Not applicable

Relation is a bidireccional one to many between the IDs of the ranges:

 

Ranges.PNG

 

@Zubair_Muhammad Thanks for your assistance!

 

Matt

Anonymous
Not applicable

Hi again, 

 

Just to let you know we've managed to figure it out with the following:

 

var a = CALCULATE(Max('Ranges'[Index])-1)
var b = CALCULATE(
DISTINCTCOUNT('Fleet (Cars)'[id]);
filter(
ALL('Fleet (Cars)');true());'Ranges'[Index]=a;) return b

Regards, 

 

Matt

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors