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
sonshine14916
Regular Visitor

Value based on the first and last day of the month

I have a Dispatch planner table which has the following columns:

 

sonshine14916_0-1709228974858.png

 

I want create 2 measures as below:

 

1) Measure-1:  Get the OpeningStock based on the first day of the month as a list:

sonshine14916_1-1709229042818.png

 

2) Measure-2: Get the ClosingStock based on the last day of the month as a list:

 

sonshine14916_2-1709229060241.png

 

I tried using the Calculate measure and filters but I'm not getting it in the list format.

Thank you in advance. 

 

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

Hi @sonshine14916 ,

The Table1 ‘s data is shown below:

vzhouwenmsft_0-1709270250303.png

Please follow these steps:
1. Use the following DAX expression to create a table named ‘First day of the month’

 

First day of the month = FILTER('Table1','Table1'[Date].[Day] = 1)

 

vzhouwenmsft_1-1709270369550.png

 

2. Use the following DAX expression to create a table named ‘Last day of the mont'

 

Last day of the month = FILTER(ADDCOLUMNS( VALUES(Table1),"Last day",EOMONTH('Table1'[Date],0)),[Date] = [Last day])

 

vzhouwenmsft_2-1709270389295.png

3. Final output

vzhouwenmsft_3-1709270417805.png

vzhouwenmsft_4-1709270424649.png

vzhouwenmsft_5-1709270434643.png

 

vzhouwenmsft_6-1709270446374.png

 


Best Regards,
Wenbin Zhou
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

7 REPLIES 7
talespin
Solution Sage
Solution Sage

 
In your visual, drop the Date column and this measure.
 
Opening Stock =
VAR _SelDate = SELECTEDVALUE('Table'[Date])
VAR _MthStartDate = EOMONTH(_SelDate, -1) + 1
RETURN IF(_SelDate = _MthStartDate, SELECTEDVALUE('Table'[OpeningStock]), BLANK())
 
Closing Stock =
VAR _SelDate = SELECTEDVALUE('Table'[Date])
VAR _MthStartDate = EOMONTH(_SelDate, 0)
RETURN IF(_SelDate = _MthStartDate, SELECTEDVALUE('Table'[ClosingStock]), BLANK())
 
talespin_0-1709283977602.png

 

Hi @talespin , thanks for your inputs. It works as well...

 

Best regards,

GK

hi @sonshine14916 

 

You're welcome.

v-zhouwen-msft
Community Support
Community Support

Hi @sonshine14916 ,

The Table1 ‘s data is shown below:

vzhouwenmsft_0-1709270250303.png

Please follow these steps:
1. Use the following DAX expression to create a table named ‘First day of the month’

 

First day of the month = FILTER('Table1','Table1'[Date].[Day] = 1)

 

vzhouwenmsft_1-1709270369550.png

 

2. Use the following DAX expression to create a table named ‘Last day of the mont'

 

Last day of the month = FILTER(ADDCOLUMNS( VALUES(Table1),"Last day",EOMONTH('Table1'[Date],0)),[Date] = [Last day])

 

vzhouwenmsft_2-1709270389295.png

3. Final output

vzhouwenmsft_3-1709270417805.png

vzhouwenmsft_4-1709270424649.png

vzhouwenmsft_5-1709270434643.png

 

vzhouwenmsft_6-1709270446374.png

 


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

 

Hi Wenbin Zhou,

thank you very much for the solution. It works. 

 

Kind regards,

GK

lbendlin
Super User
Super User

Seems a bit redundant unless you have scenarios where the closing stock of the prior month doesn't match the opening stock of the new month?

 

Which measures have you tried?

Hi @Ibendlin , you are correct, this may be redundant but I plan to use it for other purposes. Thanks for the feedback.

 

Best regards,

GK

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!

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.