Forum Discussion
Boycie92
8 years agoResolver I
Direct Query First and Last Dates
Hi I’m wondering if someone can help, I posted a topic a while ago about how to identify the First and Last Dates (link for further details): http://community.powerbi.com/t5/Desktop/First...
- 8 years ago
Then we need to create another new measure to calculate the count of productId.
Count ProductId = CALCULATE ( COUNTROWS ( PowerBiTable1 ), FILTER ( ALL ( PowerBiTable1 ), PowerBiTable1[ProductId] = MAX ( PowerBiTable1[ProductId] ) ) )And the final measure will be:
Identifier = IF ( PowerBiTable1[Count ProductId] = 1, "Unique", IF ( MIN ( PowerBiTable1[TransactionDate] ) = PowerBiTable1[FirstTransactionDate], "First", IF ( MAX ( PowerBiTable1[TransactionDate] ) = PowerBiTable1[LastTransactionDate], "Last", BLANK () ) ) )Thanks,
Xi Jin.
v-xjiin-msft
8 years agoSolution Sage
Then we need to create another new measure to calculate the count of productId.
Count ProductId =
CALCULATE (
COUNTROWS ( PowerBiTable1 ),
FILTER (
ALL ( PowerBiTable1 ),
PowerBiTable1[ProductId] = MAX ( PowerBiTable1[ProductId] )
)
)And the final measure will be:
Identifier =
IF (
PowerBiTable1[Count ProductId] = 1,
"Unique",
IF (
MIN ( PowerBiTable1[TransactionDate] ) = PowerBiTable1[FirstTransactionDate],
"First",
IF (
MAX ( PowerBiTable1[TransactionDate] ) = PowerBiTable1[LastTransactionDate],
"Last",
BLANK ()
)
)
)Thanks,
Xi Jin.
Jon928
7 years agoRegular Visitor
Thanks Xi Jin
I tried the code and I am getting the error "Function 'FILTER' is not supported in this context in DirectQuery mode."?