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
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
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.