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
Riff
Frequent Visitor

Dynamic TOP (companies having 75% of market at selected period)

Hello!

Lets imagine that we have a dataset like this:

CompanyYearNum Of Sales
a201750
b201760
c201770
d201780
e201790
f2017100
a201845
b201855
c201865
d201830
e201820
f201810
a2019100
b201920
c201980
d201945
e201930
f201915

 

And we have to create a matrix with a set of columns representing only Companies having a 75% of market at a selected period (for example, for 2017 it must be only c, d, e and f columns in the matrix)

 

On changing the period the column set must be automatically changed.

 

Is this possible?

 

Thank you!

1 ACCEPTED SOLUTION

Hi @Riff ,

 

We can use the following measure to archive your requirement:

 

Measure = 
VAR totalsales =
    SUMX ( ALLSELECTED ( 'Table' ), [Num Of Sales] )
VAR t =
    ADDCOLUMNS (
        ALLSELECTED ( 'Table' ),
        "Index", RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Num Of Sales] ) ),
            ,
            ASC,
            DENSE
        )
    )
VAR t2 =
    ADDCOLUMNS (
        t,
        "total", SUMX (
            FILTER (
                SELECTCOLUMNS ( t, "I", [Index], "s", [Num Of Sales] ),
                [Index] <= [I]
            ),
            [s]
        )
    )
RETURN
    IF (
        RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Num Of Sales] ) ),
            ,
            ASC,
            DENSE
        )
            >= MAXX ( FILTER ( t2, [total] >= totalsales * 0.75 ), [Index] ),
        SUM ( 'Table'[Num Of Sales] ),
        BLANK ()
    )

20.PNG21.PNG22.PNG

 

 

 

BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @Riff ,

 

We can use a measure as value to meet your requirement:

 

Measure = 
VAR sumr =
    COUNTROWS ( ALLSELECTED ( 'Table' ) )
RETURN
    IF (
        RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( [Num Of Sales] ) ),
            SUM ( 'Table'[Num Of Sales] ),
            ASC,
            DENSE
        )
            > ROUNDUP ( 0.25 * sumr, 0 ),
        SUM ( 'Table'[Num Of Sales] ), -- Or Other Value You Want To Show
        BLANK ()
    )

22.PNG23.PNG

 

 

 

BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello, @v-lid-msft ! Thank you for you answer.

 

If i got it right, your solve shows the 75% of total count of companies. I mean, if we have 8 companies, your  solve will always show top 6 of them. Probably I did not explain the task enough clear. I need a list of companies that have 75% of sales at market. So for example if we have 6 companies where one of them has 75 sales at year and every of other 5 companies has only 5 sales (total for all of 6 is 100), then we have to get only 1st company because it has 75% of market alone.

 

Thank you!

Hi @Riff ,

 

We can use the following measure to archive your requirement:

 

Measure = 
VAR totalsales =
    SUMX ( ALLSELECTED ( 'Table' ), [Num Of Sales] )
VAR t =
    ADDCOLUMNS (
        ALLSELECTED ( 'Table' ),
        "Index", RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Num Of Sales] ) ),
            ,
            ASC,
            DENSE
        )
    )
VAR t2 =
    ADDCOLUMNS (
        t,
        "total", SUMX (
            FILTER (
                SELECTCOLUMNS ( t, "I", [Index], "s", [Num Of Sales] ),
                [Index] <= [I]
            ),
            [s]
        )
    )
RETURN
    IF (
        RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Num Of Sales] ) ),
            ,
            ASC,
            DENSE
        )
            >= MAXX ( FILTER ( t2, [total] >= totalsales * 0.75 ), [Index] ),
        SUM ( 'Table'[Num Of Sales] ),
        BLANK ()
    )

20.PNG21.PNG22.PNG

 

 

 

BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lid-msft  Thank you! It works great!

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.

Top Solution Authors