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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ArashZ
Helper I
Helper I

top N Percentage of total

Hi,

 

I would like to have a graph to calculate the top 2 languages with their percentage of the total for the table below:

 

UserLanguage
AEnglish
AFrench
BEnglish
BFrench
BFrench
CEnglish
DEnglish
ESpanish
FEnglish

 

The answer should look like the graph below. Please note that the answers should show the English and French with 55.56 and 33.33 percent respectively.

ArashZ_0-1653063915123.png

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I assume the table has a column (Index column or date column, for instance) to differenciate each row that is shown in the question.

 

Untitled.png

 

Top two count percent: =
VAR _totalcount =
    CALCULATE ( COUNTROWS ( Data ), REMOVEFILTERS () )
VAR _toptwocount =
    CALCULATE (
        COUNTROWS ( Data ),
        KEEPFILTERS (
            TOPN ( 2, ALL ( Data[Language] ), CALCULATE ( COUNTROWS ( Data ) ), DESC )
        )
    )
RETURN
    DIVIDE ( _toptwocount, _totalcount )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I assume the table has a column (Index column or date column, for instance) to differenciate each row that is shown in the question.

 

Untitled.png

 

Top two count percent: =
VAR _totalcount =
    CALCULATE ( COUNTROWS ( Data ), REMOVEFILTERS () )
VAR _toptwocount =
    CALCULATE (
        COUNTROWS ( Data ),
        KEEPFILTERS (
            TOPN ( 2, ALL ( Data[Language] ), CALCULATE ( COUNTROWS ( Data ) ), DESC )
        )
    )
RETURN
    DIVIDE ( _toptwocount, _totalcount )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors