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.
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.
Date | Aspect | Value |
January 2020 | Responsibility | 1 |
January 2020 | Validity | 0 |
January 2020 | Satefy | -1 |
January 2020 | Guarantee | -1 |
February 2020 | Responsibility | 0 |
February 2020 | Validity | -1 |
February 2020 | Satefy | 0 |
February 2020 | Guarantee | 0 |
March 2020 | Responsibility | -1 |
March 2020 | Validity | -1 |
March 2020 | Satefy | -1 |
March 2020 | Guarantee | 1 |
Solved! Go to Solution.
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))
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)))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |