简体   繁体   中英

DAX Measure SUM based on slicers

I have the following data:

Table A

Emp_ID, Weekending, Date, Dept_ID, Status, Hrs

Table B

Dept_ID, Dept_Nm, Dept_HOD (relationship: Dept_ID)

I would like to create a matrix table with the following:

Columns: Weekending
Rows: Emp_ID
Value: Using DAX measure if(Status="F",SUM(Hrs)-44,SUM(Hrs)-22)

where the table can be controlled by the Slicers: Weekending, Dept_Nm, Dept_HOD

Any advice on how I can create the DAX measure?

在此处输入图像描述

The red box ID are not suppose to be there as they are not in the selected department

I'm on the go, so I'll just type from the top of my head. I would use SUMMARIZE with SUMX. From what I can see, you want to summarise numbers weekly as well. This would be something along these lines:

SUMX(SUMMARIZE('Table A', [Emp_ID], [Status], [Weekending], "Hrs", SUM([Hrs])), [Hrs] - IF([Status] = "F", 44, 22)) .

Don't have means to check it atm, if it doesn't work, let me know.

What it does is it creates a calculated table that summarises hours by employee, status and week ending. Then based on that table, it subtracts 44 or 22, depending on the status.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM