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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
niteshtrehan89
Helper III
Helper III

Calculating the rework using previous department

Need a quick help from the communty.

 

below is the raw data. highlighted are the rework cases

 

Case Number

Department

Out time

1

D1

1

1

D2

2

1

D2

3

1

D2

4

1

D3

5

1

D3

6

1

D1

7

1

D1

8

1

D4

9

1

D4

10

2

D1

11

2

D2

12

2

D2

13

2

D2

14

2

D3

15

2

D3

16

2

D1

17

2

D1

18

2

D4

19

2

D4

20

2

D3

21

3

D1

22

3

D2

23

3

D3

24

3

D4

25

4

D1

26

4

System

27

4

D1

28

4

D2

29

4

D3

30

4

D4

31

 

We need to create a measure based on the condition if the same Department is tagged again to the same from a new previous department then it will marked as rework. Need to ignore if the department is System.

 

Final Output

DepartmentNumber of reworksTotal Cases
D124
D204
D314
D404

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @niteshtrehan89 

 

My solution is as below. I create a new table to help the calculation. (I add an Index column to the raw table with Power Query Editor. If your "Out time" column has the same meaning, you can use it instead.)

Table 2 = SUMMARIZE('Table','Table'[Case Number],'Table'[Department],"all",
var minIndex = MIN('Table'[Index])
var maxIndex = MAX('Table'[Index])
var departmentTable = CALCULATETABLE(VALUES('Table'[Department]),ALLEXCEPT('Table','Table'[Case Number]),'Table'[Index]>=minIndex,'Table'[Index]<=maxIndex)
return
CONCATENATEX(departmentTable,'Table'[Department],","))

vjingzhang_0-1655714402421.png

 

According to above table, if "all" column has other values except "System" and the Department value on the same row, it means this Department is tagged again for the case. So create a new column

Is reworked = IF(NOT(CONTAINSSTRING('Table 2'[all],",")), 0, IF('Table 2'[all] IN {"System"&","&'Table 2'[Department], 'Table 2'[Department]&","&"System"}, 0, 1))

vjingzhang_1-1655715488344.png

 

Output

vjingzhang_2-1655715708881.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @niteshtrehan89 

 

My solution is as below. I create a new table to help the calculation. (I add an Index column to the raw table with Power Query Editor. If your "Out time" column has the same meaning, you can use it instead.)

Table 2 = SUMMARIZE('Table','Table'[Case Number],'Table'[Department],"all",
var minIndex = MIN('Table'[Index])
var maxIndex = MAX('Table'[Index])
var departmentTable = CALCULATETABLE(VALUES('Table'[Department]),ALLEXCEPT('Table','Table'[Case Number]),'Table'[Index]>=minIndex,'Table'[Index]<=maxIndex)
return
CONCATENATEX(departmentTable,'Table'[Department],","))

vjingzhang_0-1655714402421.png

 

According to above table, if "all" column has other values except "System" and the Department value on the same row, it means this Department is tagged again for the case. So create a new column

Is reworked = IF(NOT(CONTAINSSTRING('Table 2'[all],",")), 0, IF('Table 2'[all] IN {"System"&","&'Table 2'[Department], 'Table 2'[Department]&","&"System"}, 0, 1))

vjingzhang_1-1655715488344.png

 

Output

vjingzhang_2-1655715708881.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.