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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gvlado
Advocate III
Advocate III

Count number of days im month and cumulative count of days by month for each year

Hello !
Need help to find solution for cumulative number of days mont by month over the years.
For each year I am looking for days per month - will use it in other calculations
For each month in the year I am looking for cumulative number of days by month (sum month days)
How to get such a columns - see printscreen

 

gvlado_0-1720160092355.png

Thanks a lot

 

1 ACCEPTED SOLUTION
gvlado
Advocate III
Advocate III

I think I found solution and want to share with you 

------------
Days per month
= CALCULATE (
    COUNT ('Calendar'[Date] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]= MAX ( 'Calendar'[Year] )
            && 'Calendar'[Monthnumber] = MAX ( 'Calendar'[Monthnumber])
            && 'Calendar'[Date] <= TODAY ()
    ))
---------------
Sum month days =
DATEDIFF(
STARTOFYEAR('Calendar'[Date]),
ENDOFMONTH( 'Calendar'[Date]),DAY)

It works for me

View solution in original post

6 REPLIES 6
gvlado
Advocate III
Advocate III

I think I found solution and want to share with you 

------------
Days per month
= CALCULATE (
    COUNT ('Calendar'[Date] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]= MAX ( 'Calendar'[Year] )
            && 'Calendar'[Monthnumber] = MAX ( 'Calendar'[Monthnumber])
            && 'Calendar'[Date] <= TODAY ()
    ))
---------------
Sum month days =
DATEDIFF(
STARTOFYEAR('Calendar'[Date]),
ENDOFMONTH( 'Calendar'[Date]),DAY)

It works for me
ThxAlot
Super User
Super User

Simple enough

 

YTD Days = EOMONTH(DATE([Yr],[Mth],1),0) - DATE([Yr],1,1) + 1

 

ThxAlot_1-1720164892967.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



It gives me only one date day back ???
What I don't understand
Here it is what I tried

YTD Days = EOMONTH(DATE('Calendar'[Year],'Calendar'[Monthnumber],1),0)-DATE('Calendar'[Year],1,1)+1
bhanu_gautam
Super User
Super User

@gvlado , For this first make sure you have one date table if not then create using below DAX

DateTable =
ADDCOLUMNS (
CALENDAR (DATE(2010, 1, 1), DATE(2025, 12, 31)),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Day", DAY([Date]),
"MonthYear", FORMAT([Date], "MMM YYYY")
)

 

Then create a new column in Date Table for number of days in each month

DaysInMonth =
DAY ( EOMONTH ( DateTable[Date], 0 ) )

 

 

Create a new column in the Date table to calculate the cumulative number of days by month:

 

CumulativeDays =
VAR CurrentYear = DateTable[Year]

 

Go to the Report view.
Click on the Table visualization icon to create a new table visualization.
Drag the following fields from the Date table to the Values area of the table visualization:
Year
MonthName
DaysInMonth
CumulativeDays
VAR CurrentMonth = DateTable[Month]
RETURN
CALCULATE (
SUM ( DateTable[DaysInMonth] ),
FILTER (
DateTable,
DateTable[Year] = CurrentYear &&
DateTable[Month] <= CurrentMonth
)
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






What I did wrong?

Created column and it is 0K
DaysInMonth =
DAY(EOMONTH('Calendar'[Date],0))
but
Created column is not 0K
CumulativeDays =
VAR CurrentYear='Calendar'[Year]
VAR CurrentMonth = 'Calendar'[Monthnumber]

RETURN
CALCULATE (
SUM ( 'Calendar'[DaysInMonth] ),
FILTER (
'Calendar',
'Calendar'[Year] = CurrentYear &&
'Calendar'[Monthnumber] <= CurrentMonth
)
)

gvlado_0-1720166165058.png

 

@gvlado , The issue was due to Granuality we need cummulative days at month level, I have created new summarized table for this attaching PBIX file with complete solution




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.