Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Asim458
New Member

TopN with Date filter e.g ( i want to get top 10 skus in last six months

Top25Skus =
VAR SelectedBrand = SELECTEDVALUE('Shift item codes'[Brand])
RETURN
CALCULATE(
    SUMX(
        TOPN(25, FILTER('Shift item codes', 'Shift item codes'[Brand] = SelectedBrand), [Total Purchases], DESC),
        [Total Purchases]
    )
)
1 ACCEPTED SOLUTION
Daoud_H
Helper I
Helper I

Hi @Asim458,

 

I suppose you want something like that : 

Top25Skus =
VAR SelectedBrand = SELECTEDVALUE('Shift item codes'[Brand])
VAR SixMonthsAgo = EOMONTH(TODAY(), -6) + 1
RETURN
CALCULATE(
    SUMX(
        TOPN(
            25, 
            FILTER(
                'Shift item codes', 
                'Shift item codes'[Brand] = SelectedBrand && 'Shift item codes'[Date] >= SixMonthsAgo
            ), 
            [Total Purchases], 
            DESC
        ),
        [Total Purchases]
    )
)

View solution in original post

1 REPLY 1
Daoud_H
Helper I
Helper I

Hi @Asim458,

 

I suppose you want something like that : 

Top25Skus =
VAR SelectedBrand = SELECTEDVALUE('Shift item codes'[Brand])
VAR SixMonthsAgo = EOMONTH(TODAY(), -6) + 1
RETURN
CALCULATE(
    SUMX(
        TOPN(
            25, 
            FILTER(
                'Shift item codes', 
                'Shift item codes'[Brand] = SelectedBrand && 'Shift item codes'[Date] >= SixMonthsAgo
            ), 
            [Total Purchases], 
            DESC
        ),
        [Total Purchases]
    )
)

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors