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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Count projects where CY20 total spend is zero

Hi,


I am trying to write a DAX measure to count the no. of projects where the NET total spend this year is ZERO.

 

It mostly works but I have projects where they spend say $100 in February 2020, then -$100 in Nov 2020 - leading to a net total spend of ZERO - however, my DAX counts this project as a project that has non-zero spend.

In the table below - the no. of projects with zero net spend in 2020 should be two projects i.e. AAA and CCC

 

But my measure counts one project i.e. CCC

 

Here are my two measures - the second measure allows me to calculate 2020 spend.

Project Count = calculate(
DISTINCTCOUNT('[Project ID])
,FILTER('Table', [CY20 Spend]=0)
)
 
CY20 Spend=
CALCULATE(
SUM([Value]),
'Table'[Date].[Year] = 2020
)

 

Project IDDateValue ($)
AAA1/1/2020-100
AAA1/3/202050
AAA1/4/202050
BBB1/1/202050
CCC1/1/20200

CCC

1/2/20200
2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try a measure like

countx(filter(summarize('Table', 'Table'[Project ID], "_1",[CY20 Spend]+0),[_1]=0),[Project ID])

 

I assumed your measure CY20 Spend working correctly

 

or try measure like with date table

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
wdx223_Daniel
Community Champion
Community Champion

@Anonymous 

Project Count = calculate(
DISTINCTCOUNT('[Project ID])
,FILTER(ALL('Table'[Project ID]), [CY20 Spend]=0)
)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.