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
Anonymous
Not applicable

Getting value from start of this month

Hello everyone,

 

I want to retrieve a "HEADCOUNT" value on the first day of the current month, using DAX.

 

SoundChimera_0-1668999274227.png

How should I approach this? I feel like the answer's right in front of me, but have not had luck so far.

 

Thanks.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below whether it suits your requirement.

 

Headcount measure: =
CALCULATE (
    MAX ( 'TableName'[HEADCOUNT] ),
    'TableName'[capturedate]
        = EOMONTH ( TODAY (), -1 ) + 1
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

Something like this?

 

FreemanZ_0-1669010195388.png

HEADCOUNT2 =
VAR CurrentMonth = MONTH ('Table'[capturedate])
VAR CurrentYear = YEAR ('Table'[capturedate])
VAR MinDateInMonth =
MINX(
    FILTER (
        ALL('Table'[capturedate]),
        MONTH ('Table'[capturedate]) = CurrentMonth&&
        YEAR ('Table'[capturedate]) = CurrentYear
    ),
    'Table'[capturedate]
)
VAR ValueInMonth =
CALCULATE(
     VALUES('Table'[headcount]),  
    'Table'[capturedate] = MinDateInMonth,
    ALL()
)
RETURN
ValueInMonth
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below whether it suits your requirement.

 

Headcount measure: =
CALCULATE (
    MAX ( 'TableName'[HEADCOUNT] ),
    'TableName'[capturedate]
        = EOMONTH ( TODAY (), -1 ) + 1
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Thank you, it worked!

 

Is there also a way to extract the same value from the first day, but of the previous month (instead of the current)?

Hi,

Thank you for your feedback.

Please try writing a measure like below.

The link down below, that describes about EOMONTH DAX function, might help.

 

Headcount measure Prev.month: =
CALCULATE (
    MAX ( 'TableName'[HEADCOUNT] ),
    'TableName'[capturedate]
        = EOMONTH ( TODAY (), -2 ) + 1
)

 

 https://dax.guide/eomonth/

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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! Prices go up Feb. 11th.

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.