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
SammuelM
Helper I
Helper I

How do I write a Dax statement that returns the current counts whenever I filter for a TEam

Below is my sample table and I'd like to write a Dax statement that returns the current count
whenever I filter for Team A or B. Ideally, the current count per team would be on a card in power BI.


| team | yearmonth | active_cnt |
|-------:|:----------|------------:|
| a | 2023-06 | 10 |
| a | 2023-07 | 15 |
| a | 2023-08 | 30 |
| b | 2023-06 | 15 |
| b | 2023-07 | 25 |
| b | 2023-08 | 30 |

Below was my attempt but it returned a blank response:

CurrentCountPerTeam =
SUMX(
FILTER(
'Query1',
'Query1'[yearmonth] = YEAR(TODAY()) * 100 + MONTH(TODAY())
),
'Query1'[active_cnt]
)

1 ACCEPTED SOLUTION

Solution. Thank you all.

 

CurrentCountPerTeam =
VAR __CurrentYearMonth = DATE(YEAR(TODAY()), MONTH(TODAY()), 1)
RETURN
SUMX(
FILTER(
'Query1',
'Query1'[cyearmonth] = __CurrentYearMonth
),
'Query1'[active_cnt]
)

 

 

View solution in original post

13 REPLIES 13
parry2k
Super User
Super User

@SammuelM what is not working when you add the measure that I provided in the most recent reply? if it is not working, share your pbix file with the expected output. It is very hard to work on the replies without understanding the data.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@SammuelM I see, you are formatting it as YYYY-MM, which is fine. I'm still not sure what you are looking for but try this:

 

CurrentCountPerTeam =

SUMX(
FILTER(
'Query1',
'Query1'[yearmonth] = TODAY ()
),
'Query1'[active_cnt]
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

So, I want to create a calculation that shows the latest count per team when I filter for the that Team. So if I filter for Team A, I'd liker to see hte count for the current month and year.

parry2k
Super User
Super User

@SammuelM seems like yearmonth column in your table is stored as a text, if that is the case then do this:

 

CurrentCountPerTeam =
VAR __Current = FORMAT ( TODAY (), "YYYY-MM" )
RETURN
SUMX(
FILTER(
'Query1',
'Query1'[yearmonth] = __Current
),
'Query1'[active_cnt]
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Capture91923.PNG

It's actually a year-month date. 

Syndicate_Admin
Administrator
Administrator

Try this to see how it is.

RecuentoActualPorEquipo =
CALCULATE(
SUM('Consulta1'[active_cnt]),
FILTER(
'Consulta1',
'Consulta1'[Equipo] = "a" || 'Consulta1'[Equipo] = "b"
),
LASTNONBLANK('Consulta1'[añomes], 1)
)

Solution. Thank you all.

 

CurrentCountPerTeam =
VAR __CurrentYearMonth = DATE(YEAR(TODAY()), MONTH(TODAY()), 1)
RETURN
SUMX(
FILTER(
'Query1',
'Query1'[cyearmonth] = __CurrentYearMonth
),
'Query1'[active_cnt]
)

 

 

@pacomase1 Thank you but Can I get an english translation please?

CurrentCountPerTeam =
SUM('Query1'[active_cnt]),
FILTER(
'Query1',
'Query1'[team] = "a" || 'Query1'[team ] = "b"
),
LASTNONBLANK('Query1'[yearmonth], 1)
)

Thank you. But I have multiples teams(roughly 40). How do I account for all 40 instead of just 'a' & 'b'. The data you in my original post was just a sample

parry2k
Super User
Super User

@SammuelM what do you define as a current?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k The latest month would be current. So if there was a september entry then once  I filter for a particular team I should see the count for that team for the current year & month

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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