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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
admin11
Memorable Member
Memorable Member

How to insert condition to filter salary amount into expression YTD expense ?

Hi All

 

I have this expression , which return YTD total expense amount :- 

_YTD_EXP_ = CALCULATE(CALCULATE(GL[AMOUNT_EXP_],DATESYTD('Date'[Date],"12/31")))
 
The total YTD expense break into 2 expense consist of :-
1_EXP_SALARY_
2. General expense
 
 The 1_EXP_SALARY_ field expression as below :-
 
1_EXP_SALARY_ =
SWITCH(
TRUE(),
'GL'[GL Code] = 81651
|| 'GL'[GL Code] = 80351
|| 'GL'[GL Code] = 80551
|| 'GL'[GL Code] = 91751
|| 'GL'[GL Code] = 90611
, "YES",
BLANK()
)
 
Now i need to insert 1_EXP_SALARY_ into YTD total expression  :-
_YTD_EXP_Salary_ = CALCULATE(CALCULATE(GL[AMOUNT_EXP_],DATESYTD('Date'[Date],"12/31",1_EXP_SALARY_)))
 
Above is not working , hope some one can share with me,
 
Paul
 
 
 
1 ACCEPTED SOLUTION

@amitchandak 

 

Thank you for your sharing. i just got the reply from below post , which is working fine  :-

 

https://community.powerbi.com/t5/Desktop/How-to-insert-condition-into-my-YTD-EXP-expression/m-p/1971...

 

Paul

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@admin11 , Try like

 

_YTD_EXP_ = CALCULATE(GL[AMOUNT_EXP_],DATESYTD('Date'[Date],"12/31"),filter('GL', 'GL'[GL Code] in {81651, 80351,80551,91751,90611}))

 

or


_YTD_EXP_ = CALCULATE(GL[AMOUNT_EXP_],DATESYTD('Date'[Date],"12/31"),1_EXP_SALARY_ = "Yes")

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

Thank you for your sharing. i just got the reply from below post , which is working fine  :-

 

https://community.powerbi.com/t5/Desktop/How-to-insert-condition-into-my-YTD-EXP-expression/m-p/1971...

 

Paul

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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