Price group segmantation pattern not working for last year value

SampleFile.pbix (3.5 MB) Hello everyone, i use the great segmentaion pattern from the dax pattern site and get the right result for the this year values.
TransactionCount (Price Group) =
var TransactionsInSegment =
FILTER(ALLSELECTED(‘Transaction’),
var AvgSalesPrice = [Avg sales price]
var SegmentForPrices =
FILTER(PriceGroup,
Not ISBLANK(AvgSalesPrice)
&& PriceGroup[Min]<=AvgSalesPrice
&& PriceGroup[Max]>=AvgSalesPrice
)
VAR IsTransactionsInSegments = NOT ISEMPTY ( SegmentForPrices )
Return IsTransactionsInSegments
)
var Result =
CALCULATE(
COUNTROWS(‘Transaction’),
KEEPFILTERS(TransactionsInSegment)
)
Return Result
But I do not get any values for the same period last year.

Does anyone have any idea how I have to change the formula. Here is an sample file, from my data model.

Hi @Mario,

First. Thanks for providing a PBIX and as much detail as possible :+1:

@AntrikshSharma, might be able to provide a more comprehensive explanation.
But with KEEPFILTERS the original filter context is preserved, so try this instead.

TransactionCount LY (Price Group) v2 = 
CALCULATE( [TransactionCount (Price Group)],
    DATEADD( 'date'[Datum], -1, YEAR )
) 

I hope this is helpful.

2 Likes

@Melissa Before looking into KEEPFILTERS the main problem is he/she is using Average measure on a fact table. Even if we would start with easier static segmentation first by denormalizing price group key into transaction table, the problem would be why Average is being used, Average of transaction table would be 1 value and that only bring 50 to 79,99 to transaction table.

@Mario One of the main thing that you missed is explaining what you are trying to achieve, please spend some time and draft a post that can help others in understanding your requirement.

Thanks for sharing your insights @AntrikshSharma
All valid points to consider!
:+1:

1 Like