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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
JAB
Advocate II
Advocate II

Count number of days with a negative accumulated sum

I have created two seperate measures which are accumulating over the calendar.

 

Measure 1 is:

Measure 1 :=
VAR LastVisibleDate =
MAX ( 'Calendar'[CalendarDate] )
VAR Result =
CALCULATE (
Sum(‘Table1’[Value]),
FILTER (
ALL ( 'Table2'[Code] ),
'Table2'[Code] = "311"
),
'Calendar'[CalendarDate] <= LastVisibleDate
)
RETURN
Result

 

Measure 2 is similar but the filter code value is different.

Measure 3 = Measure 1 + Measure 2

This is what is shown below:

 

 Day 2Day 3Day 4Day 5Total
Item 1-10000
Item 200-11-1
Item 302-2-2-2

 

Now I need to count the number of days where Measure 3 is less than 0. 

 

My DAX knowledge is not big enough to find out how to do this. I have though of creating temporary table for the valuation but am uncertain how to do this.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@JAB , Try a measure like

countx(values(Table[Item]) , if( [Measure 3] , [item], blank()))

 

or

 

countx(summarize(Table, Table[Item], Table[date],"_1" , [Measure 3]),if( [_1] , [item], blank()))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@JAB , Try a measure like

countx(values(Table[Item]) , if( [Measure 3] , [item], blank()))

 

or

 

countx(summarize(Table, Table[Item], Table[date],"_1" , [Measure 3]),if( [_1] , [item], blank()))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi amitchandak,

Thank you for your suggestion. I took the first suggestion and it worked just fine. Appreciate your help.

Kr

JAB

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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