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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Islam
Helper V
Helper V

Need Help with complex dax formulas

hello Everyone 

this is a sample file for what i need and i explained every thing in a text box in the file and i need help 

 

and to summerize what i need exactly is that i have two date in two different tables and an initiate value in the fact table which has relationships with both other tables and i wanna based on camparing the two dates in the two tables to generate the new value based on result of dates comparison and extracted from the initiate value in the fact table

 

and here is the sample file

https://drive.google.com/file/d/1jlbkikkQfscIu4BO1bx3TnvAKMeORW3B/view?usp=sharing 

8 REPLIES 8
lbendlin
Super User
Super User

"the initial wage or base wage which i enter manually for each employee"

 

How are you planning to do that in Power BI?

Can I contact you privately sir ?

I've no ideabut I decided to put each employee base wage in employee basic details table and then calculate each raise by it's value percentage

 

 

Hi @Islam ,

Based on my understanding, I compare the Decision Apply Date with the DecImpDate. And wages increase at a rate of 50% per year. If this is not the output you expect, please describe it in more detail.

NewWage = 
var DateDiff = 
  DATEDIFF(
    MAX(dtblassignmentDec[Decision Apply Date]),
    MAX(dtblRegularAdds[DecImpDate]),
    YEAR
  )
return 
  MAX(FTransactions1[Wage]) * POWER( 1.5, DateDiff )

v-kkf-msft_0-1614737219186.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

 

I'll mention you in the more explained post

Hi @Islam ,

Try the following formula:

 

Wage growth = 
VAR MinDate =
  MINX ( 
    ALLSELECTED ( dtblassignmentDec[Decision Apply Date] ), 
    dtblassignmentDec[Decision Apply Date] 
  )
VAR currentyear =
  YEAR ( MAX ( dtblRegularAdds[DecImpDate] ) )
var YearDiff = 
  currentyear - YEAR(MinDate)
var _year = 
  IF(
    MAX(dtblRegularAdds[DecImpDate]) >= EDATE(MinDate,YearDiff*12),
    YearDiff,
    YearDiff-1
  )
VAR growthRate = 
  SUM(dtblRegularAdds[PromotionRate])
VAR Result =
  SUM ( dtblBasicEmpInfo[Wage] ) * ( 1 + growthRate ) ^ _year
RETURN
  Result

 

image.png

This is my PBIX file.

https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-lazhang_microsoft_com/ES3gq095kdxOuUztsFMK16...

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

 

 it's almost correct but unfortunately both employees got the regular add although one of them has a date differnce between his assigning date and regular add date equals to less than a year

like following picture

1.png

sure sir I'll inforn you with result and sry for sending you the explaination privately because I couldn't type it here due to site html restrictions

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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