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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors