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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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()))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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()))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.