Forum Discussion
undefined
- Anonymous5 years ago
Hi Gurukiran003
Here I will give you some advice on transforming data model and how to build measures.
Firstly, we need to build a calculated table to build a matrix visual like left up corner.
Table = GENERATE ( SUMMARIZE ( TASK, TASK[NAME], TASK[TASK], TASK[SUB] ), ADDCOLUMNS ( CALENDARAUTO (), "YEAR", YEAR ( [Date] ), "MONTH", MONTH ( [Date] ), "DAY", DAY ( [Date] ) ) )Then we need to expand leave date in Employee leave Table.
For reference: Expand a date range
We need Subtraction +1, this is the difference between our case and sample in above blog.
New Employee Leave Table.
Then we add a Leave Flag column in calculated table.
Leave Flag = IF('Table'[Date] IN VALUES('EMPLOYEE LEAVE'[Leave Day]),"L")Then build measure as below.
Measure = VAR _START = CALCULATE(MAX(TASK[START]),FILTER(ALL(TASK),TASK[NAME]=MAX('Table'[NAME])&&TASK[TASK]=MAX('Table'[TASK])&&TASK[SUB]=MAX('Table'[SUB]))) VAR _END = CALCULATE(MAX(TASK[END]),FILTER(ALL(TASK),TASK[NAME]=MAX('Table'[NAME])&&TASK[TASK]=MAX('Table'[TASK])&&TASK[SUB]=MAX('Table'[SUB]))) VAR _DayDiff = CALCULATE(COUNT('Table'[Date]),FILTER(ALL('Table'),'Table'[NAME] = MAX(TASK[NAME])&&'Table'[TASK]=MAX(TASK[TASK])&&'Table'[SUB] = MAX(TASK[SUB])&&'Table'[Date]>=_START&&'Table'[Date]<=_END&&'Table'[Leave Flag]=BLANK())) VAR _EFFORT = CALCULATE(SUM(TASK[EFFORT]),FILTER(ALL(TASK),TASK[NAME]=MAX('Table'[NAME])&&TASK[TASK]=MAX('Table'[TASK])&&TASK[SUB]=MAX('Table'[SUB]))) VAR _RESULT = IF(MAX('Table'[Date])>=_START&&MAX('Table'[Date])<=_END,IF(MAX('Table'[Leave Flag])=BLANK(),DIVIDE(_EFFORT,_DayDiff),"L")) RETURN _RESULTBuild a matrix and result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Gurukiran003
Here I will give you some advice on transforming data model and how to build measures.
Firstly, we need to build a calculated table to build a matrix visual like left up corner.
Table =
GENERATE (
SUMMARIZE ( TASK, TASK[NAME], TASK[TASK], TASK[SUB] ),
ADDCOLUMNS (
CALENDARAUTO (),
"YEAR", YEAR ( [Date] ),
"MONTH", MONTH ( [Date] ),
"DAY", DAY ( [Date] )
)
)
Then we need to expand leave date in Employee leave Table.
For reference: Expand a date range
We need Subtraction +1, this is the difference between our case and sample in above blog.
New Employee Leave Table.
Then we add a Leave Flag column in calculated table.
Leave Flag =
IF('Table'[Date] IN VALUES('EMPLOYEE LEAVE'[Leave Day]),"L")
Then build measure as below.
Measure =
VAR _START = CALCULATE(MAX(TASK[START]),FILTER(ALL(TASK),TASK[NAME]=MAX('Table'[NAME])&&TASK[TASK]=MAX('Table'[TASK])&&TASK[SUB]=MAX('Table'[SUB])))
VAR _END = CALCULATE(MAX(TASK[END]),FILTER(ALL(TASK),TASK[NAME]=MAX('Table'[NAME])&&TASK[TASK]=MAX('Table'[TASK])&&TASK[SUB]=MAX('Table'[SUB])))
VAR _DayDiff = CALCULATE(COUNT('Table'[Date]),FILTER(ALL('Table'),'Table'[NAME] = MAX(TASK[NAME])&&'Table'[TASK]=MAX(TASK[TASK])&&'Table'[SUB] = MAX(TASK[SUB])&&'Table'[Date]>=_START&&'Table'[Date]<=_END&&'Table'[Leave Flag]=BLANK()))
VAR _EFFORT = CALCULATE(SUM(TASK[EFFORT]),FILTER(ALL(TASK),TASK[NAME]=MAX('Table'[NAME])&&TASK[TASK]=MAX('Table'[TASK])&&TASK[SUB]=MAX('Table'[SUB])))
VAR _RESULT = IF(MAX('Table'[Date])>=_START&&MAX('Table'[Date])<=_END,IF(MAX('Table'[Leave Flag])=BLANK(),DIVIDE(_EFFORT,_DayDiff),"L"))
RETURN
_RESULT
Build a matrix and result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
tq🙂