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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DanJBay1978
Frequent Visitor

create a calculated column to segment selected data based on 20/80 percent split

Hi

 

Can anyone one assist with helping me understand how a can create a calculated column that segments the data selected into top 20% vs bottom 80% split of the selected data. Using the below example of 50 records - when ranked highest to lowest -flag the top 20 % (10 records) as "top20percent" and the remaining records as "bottom80Percent".

 

Thanks in advance.

 

 

ReferenceDaysFlag
215640009171Top20Percent
204643040163Top20Percent
201134031160Top20Percent
205662022156Top20Percent
201661023147Top20Percent
205140074147Top20Percent
203205017133Top20Percent
201620002122Top20Percent
201695012114Top20Percent
201193038107Top20Percent
215611018107Bottom80Percent
201134008100Bottom80Percent
20169910599Bottom80Percent
20514006599Bottom80Percent
20514004795Bottom80Percent
20169301394Bottom80Percent
21561102793Bottom80Percent
20514004989Bottom80Percent
20563500788Bottom80Percent
20566202387Bottom80Percent
20110003686Bottom80Percent
20219811085Bottom80Percent
20113402784Bottom80Percent
20166100980Bottom80Percent
20514007678Bottom80Percent
20119104777Bottom80Percent
20166301477Bottom80Percent
20110003476Bottom80Percent
20320502074Bottom80Percent
20113400269Bottom80Percent
20319807269Bottom80Percent
20512202763Bottom80Percent
20514003660Bottom80Percent
20110005359Bottom80Percent
21565300149Bottom80Percent
21510500346Bottom80Percent
20566201843Bottom80Percent
20113401637Bottom80Percent
20113402936Bottom80Percent
20113403335Bottom80Percent
20162900335Bottom80Percent
21410801835Bottom80Percent
20169904032Bottom80Percent
20310901032Bottom80Percent
20514002331Bottom80Percent
20311000529Bottom80Percent
21569000725Bottom80Percent
20168902721Bottom80Percent
21561106221Bottom80Percent
21569001214Bottom80Percent
1 ACCEPTED SOLUTION

@DanJBay1978

 

File attached as well

 

topbttm.png


Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@DanJBay1978

 

Try this calculated column

 

MyFlag_ =
VAR myref = [Reference]
VAR rowcount =
    COUNTROWS ( Table1 )
VAR Top20rows =
    SELECTCOLUMNS (
        TOPN ( INT ( rowcount * .2 ), Table1, [Days], DESC, [Reference], ASC ),
        "Ref", [Reference]
    )
RETURN
    IF ( myref IN Top20rows, "Top20 Percent", "Bottom80Percent" )

Regards
Zubair

Please try my custom visuals

@DanJBay1978

 

File attached as well

 

topbttm.png


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.