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

undefined

Hi everyone. Need your help for this one. Here's my sample data.

 

BatchKeyIDCriteria
1some1Y
1some2N
2some3Y
2some4N
2some5Y
2some6N

 

So I have a measure that calculates the count of KeyIDs with regards to a criteria:

KeyID Count = CALCULATE(COUNT(KeyID), Criteria = "Y")

I have the batch as a filter in a slicer.

So, I'm at my wits' end, and maybe you folks could help. I want to count the values of the previous batch relative to what the current filter is. 
So in this example. say the filter is Batch = 2, the measure above will evaluate to 2. Then, in another visual, I want to show the number 1 (while the filter Batch = 2, then the Batch for that visual will be 1). 


I tried using this:

CALCULATE([KeyID Count], [Batch] -1) to no avail.

Thanks for your help!

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

try to create two measures with this:

KeyIDCount := CALCULATE(COUNT(TableName[KeyID]), TableName[Criteria] = "Y")
KeyIDCountPrevBatch :=
VAR CurrentBatch = MAX(TableName[Batch])
RETURN
CALCULATE(
    [KeyIDCount],
    TableName[Batch]=CurrentBatch-1
)
 
i tried and it worked like this:
FreemanZ_0-1670246370092.png

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

That was fast! Thanks it worked! Gotta learn variables I guess.

FreemanZ
Super User
Super User

try to create two measures with this:

KeyIDCount := CALCULATE(COUNT(TableName[KeyID]), TableName[Criteria] = "Y")
KeyIDCountPrevBatch :=
VAR CurrentBatch = MAX(TableName[Batch])
RETURN
CALCULATE(
    [KeyIDCount],
    TableName[Batch]=CurrentBatch-1
)
 
i tried and it worked like this:
FreemanZ_0-1670246370092.png

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.