cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Need help with complex DAX question

Hi all,

 

I have written the following DAX code for filtered table in DAXStudio:

EVALUATE
ADDCOLUMNS ( 
	CALCULATETABLE ( 
		ADDCOLUMNS ( 
			SUMMARIZE ( 
				NATURALLEFTOUTERJOIN ( 
					Calendar544W,
					TimesheetFacts
				),
				Employees01[Person],
				TimesheetFacts[CMHRWRKS],
				TimesheetFacts[CMHRWRKI],
				Calendar544W[Date],
				Calendar544W[WeekdayNum],
				Calendar544W[IsPublicHoliday]
			),
			"Schedule", 
				MAXX ( 
					SUMMARIZE ( 
						TimesheetFacts,
						Employees01[Person],
						TimesheetFacts[CMHRWRKS],
						Calendar544W[WeekYearNum]
					),
					[CMHRWRKS]
				)
		),
		FILTER ( 
			Calendar544W,
			Calendar544W[WeekYearNum] = 202001
		),
		FILTER ( 
			Employees01,
			Employees01[Person] = 537 || Employees01[Person] = 125
		)
	),
    "# Gross hrs", CALCULATE ( SUM ( TimesheetFacts[KMHRCATSH] ) )
)
ORDER BY [Date], [Person]

The code gives the following output:

Output.png

What I want is to have the column "Schedule" to show the value of column "CMHRWRKS" individually for both persons. So P90E for all lines belonging to person 125 and P80A for all lines belonging to person 537.

 

Can anyone tell me how this can be done?

 

Rg. Erwin

1 REPLY 1
Highlighted
Super User IV
Super User IV

Re: Need help with complex DAX question

Sample source data would really help but maybe this:

 

EVALUATE
ADDCOLUMNS ( 
	CALCULATETABLE ( 
		ADDCOLUMNS ( 
			SUMMARIZE ( 
				NATURALLEFTOUTERJOIN ( 
					Calendar544W,
					TimesheetFacts
				),
				Employees01[Person],
				TimesheetFacts[CMHRWRKS],
				TimesheetFacts[CMHRWRKI],
				Calendar544W[Date],
				Calendar544W[WeekdayNum],
				Calendar544W[IsPublicHoliday]
			),
			"Schedule", 
				MAXX ( 
					FILTER ( 
						TimesheetFacts,
						Employees01[Person] = EARLIER( Employees01[Person] 
                                        ),
			                TimesheetFacts[CMHRWRKS]
				)
		),
		FILTER ( 
			Calendar544W,
			Calendar544W[WeekYearNum] = 202001
		),
		FILTER ( 
			Employees01,
			Employees01[Person] = 537 || Employees01[Person] = 125
		)
	),
    "# Gross hrs", CALCULATE ( SUM ( TimesheetFacts[KMHRCATSH] ) )
)
ORDER BY [Date], [Person]

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Super Users of the Quarter - Q2 2020

Super Users of the Quarter - Q2 2020

Who are our Super User Superstars? Who made it to the top of the leaderboards? Get the answers!

June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors