The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello,
I want to do the following:
At my company there are two shifts in a day, and the data is uploaded when each shift ends.
So I have two rows per day.
I need to create two columns (as you can see in red) that sum the hours worked and not worked per day.
The function has to take into account the day, if it is the same, it must add the two values of hours
Can anybody help me?
Solved! Go to Solution.
hi @Anonymous
try like:
Hs worked/day =
VAR _worked =
SUMX(
FILTER(
TableName,
TableName[Date]=EARLIER(TableName[Date])
),
TableName[Worked]
)
RETURN
IF([Shift]="B", _worked)
Hs unworked/day =
VAR _unworked=
SUMX(
FILTER(
TableName,
TableName[Date]=EARLIER(TableName[Date])
),
TableName[Unworked]
)
RETURN
IF([Shift]="B",_unworked)
it worked like this:
hi @Anonymous
It is more advisable to do with table visuals, like this:
2 reminders: 1) avoid the date hierarchy, 2) choose SUM for the two hour columns.
Hello, thank you for the reply.
The problem with that is I need to make other functions after with the values of hours per day. So I need to do it in DAX.
hi @Anonymous
try like:
Hs worked/day =
VAR _worked =
SUMX(
FILTER(
TableName,
TableName[Date]=EARLIER(TableName[Date])
),
TableName[Worked]
)
RETURN
IF([Shift]="B", _worked)
Hs unworked/day =
VAR _unworked=
SUMX(
FILTER(
TableName,
TableName[Date]=EARLIER(TableName[Date])
),
TableName[Unworked]
)
RETURN
IF([Shift]="B",_unworked)
it worked like this:
User | Count |
---|---|
28 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
35 | |
14 | |
12 | |
9 | |
7 |