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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AadFourpoints
Frequent Visitor

Count occurences of days which has a summed total below a certain value

Hi Community,

 

A question for a personal dashboard I have. I am counting calories (yeah, I know) and I got this source calories4 with multiple entries per date. The uniqueness in this source is the piece of food I ate with the number of calories it holds.

 

For example the month May, in the source this month got 214 entries, which represent the food I ate during the 31 days May knows.

In PowerBI the source is represented as a sum of calories per date.

 

data1.PNG

 

Today I am trying to visualize the number of days on which I ate less than 2500 calories. The month May has 7 of this kind of days and as I think I need to distinct count the dates which will be 31 in my example and then filter on those which has a sum of less than 2500 but for some reason I can't get this done:

 

NumOfGreenDays = CALCULATE( DISTINCTCOUNT( calories4[Datum] ), FILTER( calories4, calories4[Calorien] <= 2500 ))

 

data.PNG

 

Where am I making the mistake?

 

Thanks in advance and kind regards,

 

Aad

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @AadFourpoints 
Please try

NumOfGreenDays =
SUMX (
    VALUES ( calories4[Datum] ),
    INT ( CALCULATE ( SUM ( calories4[Calorien] ) ) <= 2500 )
)

View solution in original post

3 REPLIES 3
AadFourpoints
Frequent Visitor

Both thanks for replying this quick! The solution Tamerj1 posted works like a charm!  And thanks Some_big, I see the datetime format and that is a bit overkill *grin*

 

Thanks alot and kind regards,

 

Aad

tamerj1
Super User
Super User

Hi @AadFourpoints 
Please try

NumOfGreenDays =
SUMX (
    VALUES ( calories4[Datum] ),
    INT ( CALCULATE ( SUM ( calories4[Calorien] ) ) <= 2500 )
)
some_bih
Super User
Super User

Hi @AadFourpoints try to format your Datum colum as type date in Power Query step during import.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors