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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

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