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
Anonymous
Not applicable

Count same values in most recent date

Hi everyone,

 

I want to create a formula which count how many times a specific value shows up in the most recent date.
I made a sample set (see below). I want to know how many times '-1' shows up in the latest month (March). So the answer should be 3.  

DateAspectValue
January 2020Responsibility1
January 2020Validity0
January 2020Satefy-1
January  2020Guarantee -1
February 2020Responsibility0
February 2020Validity-1
February 2020Satefy0
February 2020Guarantee 0
March 2020Responsibility-1
March 2020Validity-1
March 2020Satefy-1
March 2020Guarantee 1
2 ACCEPTED SOLUTIONS
Vera_33
Resident Rockstar
Resident Rockstar

It depends on how you want to visualize it, if you just want to hard coded like this, or maybe you want a matrix, so you will have dimTable to show all the Value, then you get the CurValue=SELECTEDVALUE(dimTable[Value]), or you have a Date Table, then you need to take care the relationship as well.

 

CountValue=
VAR MaxMonth = MONTH(MAX(yourTable[Date]))
VAR CurValue = -1
RETURN
COUNTROWS(FILTER(yourTable,MONTH(yourTable[Date])=MaxMonth && yourTable[Value] = CurValue))

View solution in original post

If you just want 9, do this, but you need to take care of your date format

CountValue1=

VAR MaxYear = YEAR(MAX(yourTable[Date]))

VAR MaxMonth = MONTH(MAX(yourTable[Date]))

VAR CurValue = -1

RETURN

SUMX(

     GROUPBY(yourTable,[Location]),

     COUNTROWS(FILTER(yourTable,Year(yourTable[Date])=MaxYear && MONTH(yourTable[Date])=MaxMonth && yourTable[Value] = CurValue)))

View solution in original post

11 REPLIES 11

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.