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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
andybamber
Helper III
Helper III

Dax Measure - Lastdate

Hello All!

 

I have a file of weekly data snapshots. The file has a snapshot date stamp

I have a measure:

headcount_Max_Wk = CALCULATE(DISTINCTCOUNT(SNAP_DWH_RES_RESOURCE[resource_key]),LASTDATE(SNAP_DWH_RES_RESOURCE[snaphot_stamp]))

 

The idea is i get a distinct count based on the latest date. When you create a bar chart and show the data by business area and year/month it correctly shows the headcount... and i can see its taking the last date for the month and giving the correct distinct headount

 

However on a second visual, where the bar chart is showing job role and year/month it doesnt work correctly... its overcounting this seems to be because some people have changed their job from 1 week to another, in the same month. As you can see below Name_2 and Name_3 are examples... how do i change my measure to ignore the 1st October row of data for each?

 

excel.png

 

Cheers

 

Andy

10 REPLIES 10
Anonymous
Not applicable

@andybamber  Hi , You can use this formula . I took employee Column to get distinct count by month .

 
 
headcount_Max_Wk = CALCULATE(DISTINCTCOUNT(Sheet1[Employee]),LASTDATE(Sheet1[SnapShot Date Stamp]))

New measure.JPG

@Anonymous  thanks for your reply... Apart from using Employee field in stead of resource Key (which is effectively the unique employee ID) your measure is probably the same as mine...  i think maybe you require some additional information... so the Month is being pulled into the visual from the linked Date Dimension table, the join is from snapshot date stamp to the data.. does that help?

 

Cheers

 

Andy

Anonymous
Not applicable

@andybamber : It Will Work for that as well . you have to define BI Directional Relationship in between datetable and  your master table then it will work fine for you .
New measure.JPG


 

@Anonymous its currently set as both....

Anonymous
Not applicable

@andybamber  Can you please sample file with relevant data and kindly mask other columns.It will be great .

@Anonymous  i should also have said regarding the PBIX that the right hand bar chart is correctm showing 8 for both months, but its the one on the left with the actual role where its not counting correctly... thanks

@Anonymous PBIX ex 

@Anonymous  I have a file for you, how do i send as it wont let me attach a PBIX into a message....

 

Cheers

Andy

lbendlin
Super User
Super User

For each Employee and Month Name you want to find the latest Day of the month. Once you have that you can then lookup the Job role for that user for that date.

 

Do you need to do this in DAX or is Power Query an option too?

Hi There!

 

Dax would be the preferred option, but i'm open to a power query solution..

 

Cheers

 

Andy

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.