Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I am trying to get sum of broken items per month for each ID within status for the earliest date available in the dataset (as they continously are in dataset for next months with the same status, but I want to count it only once in the month it has broke)
Status has to be = "B". I also need to use relationship because I have already established active relation between Active items and calendar
So I was thinking of
Calculate ( SUM ( ItemID ),
Table[ItemStatus] = "B",
MIN( Table[InActiveItemsDat] ),
USERELATIONSHIP ( Table[InActiveItemsDat], Calendar[Date] )
)
however it doesnt work
Solved! Go to Solution.
Hi @Pbiuserr ,
Please try these measures to see if they return correct result.
FirstDate =
CALCULATE (
MIN ( 'Calendar'[Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[ItemStatus] = "B"
&& 'Table'[ItemID] = MAX ( 'Table'[ItemID] )
),
ALL (),
USERELATIONSHIP ( 'Calendar'[Date], 'Table'[InActiveItemsDat] )
)
IDCount =
SUMX (
'Table',
CALCULATE (
COUNTROWS ( 'Calendar' ),
FILTER ( 'Calendar', 'Calendar'[Date] = [FirstDate] ),
USERELATIONSHIP ( 'Calendar'[Date], 'Table'[InActiveItemsDat] )
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Pbiuserr , You need to try a measure like
Calculate ( SUM ( ItemID ),
Filter( Table, Table[ItemStatus] = "B" && Table[InActiveItemsDat] = minx(filter(allselected(Table), Table[ID] = Max(Table[ID])), Table[InActiveItemsDat]))
USERELATIONSHIP ( Table[InActiveItemsDat], Calendar[Date] )
)
refer
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0
Hi,
unfortunately it gives me blank value, so it doesnt count
Hi @Pbiuserr ,
Please try these measures to see if they return correct result.
FirstDate =
CALCULATE (
MIN ( 'Calendar'[Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[ItemStatus] = "B"
&& 'Table'[ItemID] = MAX ( 'Table'[ItemID] )
),
ALL (),
USERELATIONSHIP ( 'Calendar'[Date], 'Table'[InActiveItemsDat] )
)
IDCount =
SUMX (
'Table',
CALCULATE (
COUNTROWS ( 'Calendar' ),
FILTER ( 'Calendar', 'Calendar'[Date] = [FirstDate] ),
USERELATIONSHIP ( 'Calendar'[Date], 'Table'[InActiveItemsDat] )
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.