Forum Discussion
Assadujaman
3 years agoRegular Visitor
DAX help
Data table 1 Department Total Union and NOn-Union 2020 Total Union and NOn-Union 2021 Number of Union 2020 Number of Union 2021 Number of Non-Union 2020 Number of Non-Union 2021 Number of ...
- Anonymous3 years ago
Hi Assadujaman ,
Here are the steps you can follow:
1. In Power Query – Check the rest of the columns except [Department].
Result:
2. Create calculated table.
True = VAR _Department2020 = MAXX ( FILTER ( ALL ( Table2 ), 'Table2'[Termination Reason] = "A" && 'Table2'[Effective date Year] = 2020 ), 'Table2'[Department] ) VAR _Department2021 = MAXX ( FILTER ( ALL ( Table2 ), 'Table2'[Termination Reason] = "A" && 'Table2'[Effective date Year] = 2021 ), 'Table2'[Department] ) RETURN SUMMARIZE ( 'Table1', 'Table1'[Department], "2020", IF ( [Department] = _Department2020, SUMX ( FILTER ( ALL ( Table1 ), VALUE ( RIGHT ( 'Table1'[Attribute], 4 ) ) = 2020 && 'Table1'[Department] = EARLIER ( [Department] ) && CONTAINSSTRING ( 'Table1'[Attribute], "Total Union and NOn-Union" ) = TRUE () ), [Value] ) ), "2021", IF ( [Department] = _Department2021, SUMX ( FILTER ( ALL ( Table1 ), VALUE ( RIGHT ( 'Table1'[Attribute], 4 ) ) = 2021 && 'Table1'[Department] = EARLIER ( [Department] ) && CONTAINSSTRING ( 'Table1'[Attribute], "Total Union and NOn-Union" ) = TRUE () ), [Value] ) ) )3. Result:
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
Anonymous
3 years agoNot applicable
Hi Assadujaman ,
Here are the steps you can follow:
1. In Power Query – Check the rest of the columns except [Department].
Result:
2. Create calculated table.
True =
VAR _Department2020 =
MAXX (
FILTER (
ALL ( Table2 ),
'Table2'[Termination Reason] = "A"
&& 'Table2'[Effective date Year] = 2020
),
'Table2'[Department]
)
VAR _Department2021 =
MAXX (
FILTER (
ALL ( Table2 ),
'Table2'[Termination Reason] = "A"
&& 'Table2'[Effective date Year] = 2021
),
'Table2'[Department]
)
RETURN
SUMMARIZE (
'Table1',
'Table1'[Department],
"2020",
IF (
[Department] = _Department2020,
SUMX (
FILTER (
ALL ( Table1 ),
VALUE ( RIGHT ( 'Table1'[Attribute], 4 ) ) = 2020
&& 'Table1'[Department] = EARLIER ( [Department] )
&& CONTAINSSTRING ( 'Table1'[Attribute], "Total Union and NOn-Union" ) = TRUE ()
),
[Value]
)
),
"2021",
IF (
[Department] = _Department2021,
SUMX (
FILTER (
ALL ( Table1 ),
VALUE ( RIGHT ( 'Table1'[Attribute], 4 ) ) = 2021
&& 'Table1'[Department] = EARLIER ( [Department] )
&& CONTAINSSTRING ( 'Table1'[Attribute], "Total Union and NOn-Union" ) = TRUE ()
),
[Value]
)
)
)
3. Result:
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