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
Vivek26
Helper I
Helper I

Need help with a Measure without creating calculated columns

I have a scenario where I need to get the sum of specific rows if they follow a particular path. 

We need to calculate the sum of rows(column Hours) with DEPT_NAME "HR" only if it also went through the DEPT "OPS" for the same order.

For example we should consider the Orderid 1 and 3 because those order had both HR and OPS while 2 is not considered because it didn't had OPS.

Now we also need to calculate the sum of hours for these subset of orders that fullfill the above criteria ("HR" with OPS) .

Sample Data and snapshow below , Can you please help me with this ?

IDDateOrder IDDEPT NAMEHours
122-12-20231OPS10
224-12-20231FIN12
329-12-20231HR14
411-12-20232FIN20
520-12-20232HR30
614-12-20233FIN30
720-12-20233OPS40
820-12-20233HR50

 

Vivek26_0-1704363979705.png

 

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

hi, @Vivek26 

try below measure 

Measure 2 = 
CALCULATE(
     SUM('Table (3)'[hours]),
     FILTER(
        'Table (3)',
        'Table (3)'[dept name] in {"hr","ops"} && 
        'Table (3)'[order id]=MAX('Table (3)'[order id])
    )
)

 

Dangar332_0-1704569077310.png

 

code for month-year

Dangar332_1-1704569095431.png

 

View solution in original post

2 REPLIES 2
Dangar332
Super User
Super User

hi, @Vivek26 

try below measure 

Measure 2 = 
CALCULATE(
     SUM('Table (3)'[hours]),
     FILTER(
        'Table (3)',
        'Table (3)'[dept name] in {"hr","ops"} && 
        'Table (3)'[order id]=MAX('Table (3)'[order id])
    )
)

 

Dangar332_0-1704569077310.png

 

code for month-year

Dangar332_1-1704569095431.png

 

Kishore_Kadhir
Resolver II
Resolver II

Hi @Vivek26 ,

 

See if the below measure works:
TotalHourswithHRandOPS =
var concatenation = CONCATENATEX(VALUES(Dept[DeptName]), Dept[DeptName], ",")
var output = SUMMARIZE(Dept, Dept[OrderID], "Dept", SWITCH(TRUE(),
                                                    CONTAINSSTRING(concatenation, "OPS") &&
                                                    CONTAINSSTRING(concatenation, "HR"), "Yes"))
RETURN
SUMX(FILTER(output, [Dept] <> BLANK()), CALCULATE(SUM(Dept[Hours]), FILTER(Dept, Dept[DeptName] IN {"HR", "OPS"})))
 
Kishore_Kadhir_3-1704557072380.png

 


 

Thanks,

Kishore

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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