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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
cristianj
Helper IV
Helper IV

calculate top XX% from a table for each day

hello, i have a table in which for each day i have the Sales % for each product, something like:

Date | Product | Sale for that day for that product | % Sale for that day for that product from total sales for that day|

I want to make a formula, in a column which return 3 values for each day, for each product, if the product sale Procent is in the top 70% the value should be tier1, is it is in the 70% from the last 30% from total it would say tier2 and blank for the rest

something like that.

Thank you

dayproduct sales that day  total sales that day  %from total  Tier 
01.01.2023 Product05  30 1160.25862069 Tier1
01.01.2023 Product07 271160.232758621Tier1
01.01.2023Product01111160.094827586Tier1
01.01.2023Product09111160.094827586Tier1
01.01.2023Product1091160.077586207Tier2
01.01.2023Product1171160.060344828Tier2
01.01.2023Product0851160.043103448Tier2
01.01.2023Product0351160.043103448 
01.01.2023Product0651160.043103448 
01.01.2023Product0441160.034482759 
01.01.2023Product0221160.017241379 
01.02.2023Product0420840.238095238Tier1
01.02.2023Product0818840.214285714Tier1
01.02.2023Product1014840.166666667Tier1
01.02.2023Product116840.071428571Tier1
01.02.2023Product095840.05952381Tier2
01.02.2023Product025840.05952381Tier2
01.02.2023Product015840.05952381Tier2
01.02.2023Product054840.047619048 
01.02.2023Product033840.035714286 
01.02.2023Product063840.035714286 
01.02.2023Product071840.011904762 
01.03.2023Product08261290.201550388Tier1
01.03.2023Product06251290.19379845Tier1
01.03.2023Product09141290.108527132Tier1
01.03.2023Product11121290.093023256Tier1
01.03.2023Product01121290.093023256Tier1
01.03.2023Product05111290.085271318Tier2
01.03.2023Product10111290.085271318Tier2
01.03.2023Product0291290.069767442 
01.03.2023Product0451290.03875969 
01.03.2023Product0331290.023255814 
01.03.2023Product0711290.007751938 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @cristianj ,

I created a sample pbix file(see the attachment), please find the details in it.

By measures:

rank = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[day] )
RETURN
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ),
        CALCULATE ( MAX ( 'Table'[%from total] ) ),
        ,
        DESC,
        DENSE
    )
Tier = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[day] )
VAR _maxrank =
    MAXX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ), [rank] )
VAR _70perrank =
    ROUND ( _maxrank * 0.7, 0 )
RETURN
    IF (
        [rank] <= _70perrank,
        IF ( [rank] <= _70perrank * 0.7, "Tier1", "Tier2" ),
        BLANK ()
    )

By calculated columns:

Column = 
RANKX (
    FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ),
    'Table'[%from total],
    ,
    DESC,
    DENSE
)
Column 2 = 
VAR _maxrank =
    MAXX ( FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ), [Column] )
VAR _70perrank =
    ROUND ( _maxrank * 0.7, 0 )
RETURN
    IF (
        [Column] <= _70perrank,
        IF ( [Column] <= _70perrank * 0.7, "Tier1", "Tier2" ),
        BLANK ()
    )

vyiruanmsft_0-1682917637412.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @cristianj ,

I created a sample pbix file(see the attachment), please find the details in it.

By measures:

rank = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[day] )
RETURN
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ),
        CALCULATE ( MAX ( 'Table'[%from total] ) ),
        ,
        DESC,
        DENSE
    )
Tier = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[day] )
VAR _maxrank =
    MAXX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ), [rank] )
VAR _70perrank =
    ROUND ( _maxrank * 0.7, 0 )
RETURN
    IF (
        [rank] <= _70perrank,
        IF ( [rank] <= _70perrank * 0.7, "Tier1", "Tier2" ),
        BLANK ()
    )

By calculated columns:

Column = 
RANKX (
    FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ),
    'Table'[%from total],
    ,
    DESC,
    DENSE
)
Column 2 = 
VAR _maxrank =
    MAXX ( FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ), [Column] )
VAR _70perrank =
    ROUND ( _maxrank * 0.7, 0 )
RETURN
    IF (
        [Column] <= _70perrank,
        IF ( [Column] <= _70perrank * 0.7, "Tier1", "Tier2" ),
        BLANK ()
    )

vyiruanmsft_0-1682917637412.png

Best Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.