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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

how to find (current year + last year )/2

Hello Experts ,

 

how to find (current year + last year )/2   

 

I have a dax for last year(please find below dax) but i want to do (current year + last year )/2.How to find current year and last year .please advise me or share me dax .

 

# cum_last = var p1 = CALCULATE(COUNT(HRMS[EmpID]),FILTER(ALL(HRMS),[Termd] = 0))-1
VAR _selectedYear = SELECTEDVALUE('Calendar'[Date].[Year])-1
var p2 = CALCULATE(DISTINCTCOUNT(HRMS[EmpId]),FILTER(ALL(HRMS),[Termd]=0 && YEAR('HRMS'[DateofHire])<=_selectedYear) )

var result = IF(_selectedYear = 0 , p1 ,p2)
return result + 0

 

 

 

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please feel free to let me know.
 
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ibarrau
Super User
Super User

Hi. First of all you need to be sure you have a Calendar table to manage Time Intelligence.  Create two measures:

Then you can find this year :

CALCULATE( COUNT ( Table[column] ) )

Calculation for last year:

CALCULATE( COUNT ( Table[column] ) , SAMEPERIODLASTYEAR (CalentarTable[DateColumn]) )

Then you can create a third measure and use DIVIDE function to do the last part.

 

You can find how to create a Calendar Table here

 

Hope this helps,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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