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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
akhaliq7
Continued Contributor
Continued Contributor

END OF MONTH returns blanks for some months

hi

 

Wanting to use the following dax command:

 

EOM = 
CALCULATE(

    SUM('Table'[SalesYTD]),

    ENDOFMONTH('Table'[Date])

)

 

For most of the months it returns the correct values but for the months april and may it returns blanks. I have looked at the data and there are salesytd values for those months missing, I also did an equivalent formula in sql and it gave me the correct result with values for april and may.

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @akhaliq7 ,

I created some data:

vyangliumsft_0-1663571720379.png

ENDOFMONTH():
Returns the last date of the month in the current context for the specified column of dates.

ENDOFMONTH function (DAX) - DAX | Microsoft Learn

In the data I created, there was no data on the last day of April, so the entire Month of April data would be blank

vyangliumsft_1-1663571720382.png

If you want to display the last data of each month, you can use the following formula:

Here are the steps you can follow:

1. Create measure.

EOM_true =
SUMX(FILTER(ALL('Table'),
'Table'[Year]=MAX('Table'[Year])&&
'Table'[Month]=MAX('Table'[Month])&&
'Table'[Date]=
MAXX(FILTER(ALL('Table'),
'Table'[Year]=MAX('Table'[Year])&&
'Table'[Month]=MAX('Table'[Month])&&
NOT( ISBLANK('Table'[SalesYTD]))),[Date]) ),[SalesYTD])

2. Result:

vyangliumsft_3-1663571766861.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

If you are working with dates, Best Practices recommend the use of a Calendar Table. This will avoid problems related to Time Intelligence for example

 

here is one way of creating one by the gurus at sqlbi.com

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/ 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






v-yangliu-msft
Community Support
Community Support

Hi  @akhaliq7 ,

I created some data:

vyangliumsft_0-1663571720379.png

ENDOFMONTH():
Returns the last date of the month in the current context for the specified column of dates.

ENDOFMONTH function (DAX) - DAX | Microsoft Learn

In the data I created, there was no data on the last day of April, so the entire Month of April data would be blank

vyangliumsft_1-1663571720382.png

If you want to display the last data of each month, you can use the following formula:

Here are the steps you can follow:

1. Create measure.

EOM_true =
SUMX(FILTER(ALL('Table'),
'Table'[Year]=MAX('Table'[Year])&&
'Table'[Month]=MAX('Table'[Month])&&
'Table'[Date]=
MAXX(FILTER(ALL('Table'),
'Table'[Year]=MAX('Table'[Year])&&
'Table'[Month]=MAX('Table'[Month])&&
NOT( ISBLANK('Table'[SalesYTD]))),[Date]) ),[SalesYTD])

2. Result:

vyangliumsft_3-1663571766861.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

vojtechsima
Memorable Member
Memorable Member

Hi, @akhaliq7 ,
If the data in your table are missing, it should show blank as there are basically 0, if you to display 0, you can add "+0" to your measure so it doesn'T show blank. 

Otherwise, can you share your data in text form and maybe explain more, what you need?

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.