The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I am working on payroll changes monthly using power bi
I have created a measure that gives me a new Employees and thire salaries in the current month
New Employements =
VAR SelectedDate = SELECTEDVALUE('PayStatementEarningLineInquiries'[PeriodStartDate])
VAR SelectedYear = YEAR(SelectedDate)
VAR SelectedMonth = MONTH(SelectedDate)
-- Determine the previous month
VAR PreviousMonthStartDate =
IF(
SelectedMonth = 1,
DATE(SelectedYear - 1, 12, 1),
DATE(SelectedYear, SelectedMonth - 1, 1)
)
VAR PreviousMonthEndDate =
IF(
SelectedMonth = 1,
EOMONTH(DATE(SelectedYear - 1, 12, 1), 0),
EOMONTH(DATE(SelectedYear, SelectedMonth - 1, 1), 0)
)
-- Determine the current month
VAR CurrentMonthStartDate = DATE(SelectedYear, SelectedMonth, 1)
VAR CurrentMonthEndDate = EOMONTH(CurrentMonthStartDate, 0)
-- Calculate Total Earnings for the Previous Month
VAR PreviousMonthEarnings =
CALCULATE(
[TotalEarning meas],
ALLEXCEPT(
PayStatementEarningLineInquiries,
PayStatementEarningLineInquiries[Worker]
),
'(PayStatementHeaders)'[PeriodStartDate] >= PreviousMonthStartDate,
'(PayStatementHeaders)'[PeriodStartDate] <= PreviousMonthEndDate
)
-- Calculate Total Earnings for the Current Month
VAR CurrentMonthEarnings =
CALCULATE(
[TotalEarning meas],
ALLEXCEPT(
'PayStatementEarningLineInquiries',
'PayStatementEarningLineInquiries'[Worker]
),
'(PayStatementHeaders)'[PeriodStartDate] >= CurrentMonthStartDate,
'(PayStatementHeaders)'[PeriodStartDate] <= CurrentMonthEndDate
)
-- Calculate total for all rows
VAR TotalNewEmployments =
CALCULATE(
SUMX(
'PayStatementEarningLineInquiries',
IF( (CurrentMonthEarnings - PreviousMonthEarnings) < 1, CurrentMonthEarnings, BLANK())
)
)
RETURN
TotalNewEmployments
the measure work correctly
it shows me the new employees and thire salaries but it does not turn the total of all new employees
does me measure missing things ?! what should I do to make my measure truns Total Salaries
Solved! Go to Solution.
Hello @amal_01 ,
Looking at your measure i guess the last condition which you have passed Blanks() is cauing problem, kindly review that
CALCULATE( SUMX( 'PayStatementEarningLineInquiries', IF( (CurrentMonthEarnings - PreviousMonthEarnings) < 1, CurrentMonthEarnings, BLANK()) ) )
If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!
Thank You
Dharmendar S
Hi @amal_01 ,
What is the [TotalEarning meas] field in the formula? Is it possible to provide some test data and describe it so that I can answer you as soon as possible.
Best regards,
Adamk Kong
Hello @amal_01 ,
Looking at your measure i guess the last condition which you have passed Blanks() is cauing problem, kindly review that
CALCULATE( SUMX( 'PayStatementEarningLineInquiries', IF( (CurrentMonthEarnings - PreviousMonthEarnings) < 1, CurrentMonthEarnings, BLANK()) ) )
If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!
Thank You
Dharmendar S
User | Count |
---|---|
15 | |
13 | |
7 | |
6 | |
5 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |