Forum Discussion
victoryamaykin
2 years agoAdvocate I
RANKX for Measure Calculated with DatesBetween()
I'm making a leaderboard for the backroom where employees tag donations as they get sorted. Each item tagged is said to be "produced". Here's an exampe of the table called FactUserProduction. I have ...
- 2 years ago
I have a date filter calculated column called "isToday" to get the current day. The start and end of week is based on that date in the DimDates table. The DimDates table is much more involved than what I put in the sample file.
Is there another way to get items produced last week? Here's what I've been doing:Items Produced Last Week =VAR _start =DATEADD(DimDates[Start of Week], -7 , DAY)// error message here says parameter is not the correct type, but it was working beforeVAR _end =DATEADD(DimDates[End of Week], -7 , DAY)RETURNCALCULATE(SUM(FactUserProduction[ItemsStocked]),DATESBETWEEN(DimDates[Date], _start, _end))
lbendlin
2 years agoSuper User
SELECTEDVALUE(DimDates[Start of Week]) has no meaning as you don't have a filter on the date and the calendar table is connected to the data model. This would only work if you had a date picker slicer AND if it would be fed by a disconnected table.
a simple ranking formula would be
Rnk = rankx(allselected(DimUser[EmployeeName]),calculate(sum(FactUserProduction[Items Produced])))
Note that the calculation needs to happen inside the RANKX, not before.
victoryamaykin
2 years agoAdvocate I
I have a date filter calculated column called "isToday" to get the current day. The start and end of week is based on that date in the DimDates table. The DimDates table is much more involved than what I put in the sample file.
Is there another way to get items produced last week? Here's what I've been doing:
Items Produced Last Week =
VAR _start =
DATEADD(
DimDates[Start of Week], -7 , DAY)
// error message here says parameter is not the correct type, but it was working beforeVAR _end =
DATEADD(
DimDates[End of Week], -7 , DAY)
RETURN
CALCULATE(
SUM(FactUserProduction[ItemsStocked]),
DATESBETWEEN(DimDates[Date], _start, _end)
)
- lbendlin2 years agoSuper User
VAR _start = DATEADD( DimDates[Start of Week], -7 , DAY)This returns a table, not a scalar value. Not something you can use in DATESBETWEEN.
Something like
MIN(DimDates[Start of Week])-7- might work. But since you already have a calculated column for "IsToday" then you can add another one for "IsInLastWeek".