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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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