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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
balajimaikandan
Frequent Visitor

Need to get Ending numbers with a Date measure

Hi I'm working on Dax function to get data based on the Starting HC & Ending HC 

Starting HC is previous Dec month number & Ending will current month say for eg if choosing 2021 in filter  my starting will be Dec'20 & ending will Dec'21 same like if i select 2022 Aug will be my  ending HC, i have already found ending HC however i'm not to arrive the opening HC. I almost found DAX the starting HC date but i'm not able use that Starting date to filter the HC. 

this code works perfectly fine for Starting HC

Selected Ending HC =
VAR A = MAX('Raw Data HC & Attrition'[Report Date])
VAR B = CALCULATE(SUM('Raw Data HC & Attrition'[HC]),FILTER('Raw Data HC & Attrition','Raw Data HC & Attrition'[Report Date]=A))
RETURN
B
 
but  for Starting
DAX for finding Starting HC date
Selected End date =
VAR __max =MAXX('Raw Data HC & Attrition','Raw Data HC & Attrition'[Report Date].[Date])
VAR __year = YEAR(__max)
VAR __day = DAY(__max)
VAR __month = MONTH(__max)
RETURN
DATE(__year,__month-__month,__day)
 
I'm getting answer for this, but if i further use this to dax to calculate sum HC, i'm not getting the answer i only get the answer if i selected all dates if choose 2021 in filter its showing blank
 
New Starting End HC =
VAR A = [Selected End date]
VAR B = CALCULATE(SUM('Raw Data HC & Attrition'[HC]),FILTER('Raw Data HC & Attrition','Raw Data HC & Attrition'[Report Date]=A))
RETURN
B
 
please do the needful
 
 
2 REPLIES 2
balajimaikandan
Frequent Visitor

Starting HC is nothing but Ending numbers..Sample.PNG

v-easonf-msft
Community Support
Community Support

Hi, @balajimaikandan 

Sorry, I'm a little confused by your statement. Can you provide a sample pbix for research?

Is the first valid code you provided referring to "Strating HC" or "SelectedEnding HC"?

 

veasonfmsft_1-1664876566079.png

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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