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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gboss87
New Member

Trying to get a total with several requirements

I am trying to get a total of Agreement Hours but need to filter several requirements.  Here is the SQL

sum(case when Time_Entry.Agr_Header_RecID is not null and AGR_Hours = Hours_Bill and Billable_Flag = 'True' and Time_Entry.Company_RecID <> 250 then AGR_Hours else 0 end) AGR_Hours_Total

 

and here is what I have tried to do in DAX

 

Actual_AGR_Hours_total = Calculate(Sum(Switch(not(ISBLANK('Time Table'[AGR_Header_RecID])) & 'Time Table'[AGR_Hours] = 'Time Table'[Hours_Bill] & 'Time Table'[Billable_Flag] = True & 'Time Table'[company_RecID] <> 250, 'Time Table'[AGR_Hours] , 0)))
 
The table names are different from the SQL and what I pulled into Power BI fyi.  'Time Table' is correct.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @gboss87 ,

I created some data:

vyangliumsft_0-1666251890879.png

Here are the steps you can follow:

1. Create calculated column.

Actual_AGR_Hours_total =
var _if=
  FILTER('Time Table',
    'Time Table'[Agr_Header_RecID]<>BLANK() &&
    'Time Table'[AGR_Hours]='Time Table'[Hours_Bill]&&
    'Time Table'[Billable_Flag]="True"&&
    'Time Table'[Company_RecID]<>250)
return
SUMX(_if,[AGR_Hours])

2. Result:

vyangliumsft_1-1666251890881.png

If you need pbix, please click here.

 

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @gboss87 ,

I created some data:

vyangliumsft_0-1666251890879.png

Here are the steps you can follow:

1. Create calculated column.

Actual_AGR_Hours_total =
var _if=
  FILTER('Time Table',
    'Time Table'[Agr_Header_RecID]<>BLANK() &&
    'Time Table'[AGR_Hours]='Time Table'[Hours_Bill]&&
    'Time Table'[Billable_Flag]="True"&&
    'Time Table'[Company_RecID]<>250)
return
SUMX(_if,[AGR_Hours])

2. Result:

vyangliumsft_1-1666251890881.png

If you need pbix, please click here.

 

 

Best Regards,

Liu Yang

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

lukiz84
Memorable Member
Memorable Member

Why do you use SWITCH?

 

Actual_AGR_Hours_total = 
   CALCULATE(
      SUM(
         'Time Table'[AGR_Hours],
         FILTER(
            'Time Table',
            NOT(ISBLANK('Time Table'[Agr_Header_RecID])),
            'Time Table'[AGR_Hours] = 'Time Table'[Hours_Bill],
            'Time Table'[Billable_Flag] = TRUE,
            'Time Table'[company_RecID] <> 250
         )
      )
    )

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.