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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AyushAwasthi
Helper I
Helper I

Show rows having common elements

I have a "Final Data" table with columns: Company, CIK Code and Ratio. (Every row is unique)
I have a "List Table" table with columns: Company (all values from company column in Final Data table).
Then I have a "Board data" table with columns: Individual Name, Individual Id, Organization Name and Organization Id. (Multiple individuals can be on the same company and multiple companies can have same individual)
I also have a "Match Table" table with columns: Company, CIK Code (same as Final Data table), Organization Name and Organization ID (same as Board data table). It has all the rows from Final Data table matched with Board data table.


Now I want to select a target company from a slicer on List Table, and I want to show a table visual from Final Data table with values for only those companies which have the same individuals on their board as the target company. How to achieve that?

Then I want to put the average of the ratio column of only those companies into a card visual and show the rank of the target company as compared to the peers.

Like if the company is 3rd out of the 5 companies that show up as per the criteria, the card should say "3/5". How do I achieve this?

1 ACCEPTED SOLUTION

Hi @AyushAwasthi ,

Try these steps-

Create Measures

AveragePeerRatio =
VAR SelectedCIKs =
VALUES ( 'List Table'[CIK Code] )

 

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES ( 'Match Table'[Board Code] ),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES ( 'Board Data'[Individual Id] ),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES ( 'Board Data'[Organization Id] ),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES ( 'Match Table'[CIK Code] ),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
CALCULATE (
AVERAGE ( 'Final Data'[Ratio] ),
'Final Data'[CIK Code] IN PeerCIKs
)


For PeerCompanyRank :

PeerCompanyRank =
VAR SelectedCIKs =
VALUES ( 'List Table'[CIK Code] )

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES ( 'Match Table'[Board Code] ),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES ( 'Board Data'[Individual Id] ),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES ( 'Board Data'[Organization Id] ),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES ( 'Match Table'[CIK Code] ),
'Match Table'[Board Code] IN PeerOrgs
)

VAR SelectedRatio =
CALCULATE (
MAX ( 'Final Data'[Ratio] ),
'Final Data'[CIK Code] IN SelectedCIKs
)

VAR PeerTable =
FILTER (
'Final Data',
'Final Data'[CIK Code] IN PeerCIKs
)

VAR RankedTable =
ADDCOLUMNS (
PeerTable,
"Rank", RANKX ( PeerTable, [Ratio], , DESC )
)

VAR MyRank =
MAXX (
FILTER ( RankedTable, [CIK Code] IN SelectedCIKs ),
[Rank]
)

VAR TotalPeers = COUNTROWS ( PeerTable )

RETURN
FORMAT ( MyRank, "0" ) & "/" & FORMAT ( TotalPeers, "0" )



Card Visuals

1. Card for AveragePeerRatio.

  • Add a Card visual.

  • Set the Value to AveragePeerRatio.

    .

2. Card for PeerCompanyRank.

  • Add another Card visual.

  • Set the Value to PeerCompanyRank.

 Add a Table Visual

  1. Add these fields from Final data :

    • Company 

    • CIK code

Apply the Measure as a Filter

  1. With the table visual selected, go to the Filters pane on the right.

  2. Locate your new measure ShoqInPeerList.

  3. Drag ShowInPeerList into "Filters on this visual".

  4. Change the filter condition to:

    • "is"

    • "1"

 

Measure -  ShowInPeerList =
VAR SelectedCIKs =
VALUES ( 'List Table'[CIK Code] )

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES ( 'Match Table'[Board Code] ),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES ( 'Board Data'[Individual Id] ),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES ( 'Board Data'[Organization Id] ),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES ( 'Match Table'[CIK Code] ),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
IF ( 'Final Data'[CIK Code] IN PeerCIKs, 1, 0 )



If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

Find the attached pbix file for your reference.

Best Regards,
Sreeteja.
Community Support Team.

View solution in original post

22 REPLIES 22
techies
Solution Sage
Solution Sage

Hi @AyushAwasthi for peerlist, please try this measure

 

Shared Board Members Measure =
VAR SelectedCompanyMembers =
    CALCULATETABLE (
        VALUES('Board Data'[Individual Id]),
        TREATAS (
            VALUES('List Table'[CIK Code]),
            'Match Table'[CIK Code]
        ),
        'Board Data'
    )

VAR MatchingMembers =
    CALCULATETABLE (
        VALUES('Board Data'[Individual Name]),
        FILTER (
            'Board Data',
            'Board Data'[Individual Id] IN SelectedCompanyMembers
        )
    )

RETURN
        CONCATENATEX(MatchingMembers, [Individual Name], ", ")
 
ahared members measure.gif

   
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Thanks for the measure calculation, it helped in populating that column.

 

My only problem is the IsPeerCompany measure, the table is showing me only the target company. All the average ratio and the rank measures are working perfectly fine. But I am only seeing 1 company in the table visual.

Hi  @AyushAwasthi ,
Regarding the visual showing only the target company, here are a few things to check:

Visual or Page Filters: Ensure the table visual doesn’t have a filter that restricts it to just the selected company. Double-check slicers or filters pane.

Use IsPeerCompany in Visual Filter:

Add the IsPeerCompany measure to the Filters on this visual pane.

Set it to "is TRUE".
This ensures only peer companies (as defined by your logic) appear.


Test the Measure Output:

Try putting CompanyName and IsPeerCompany into a temporary table visual.

This helps verify whether the measure is correctly returning TRUE for peers.

 

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team.

 

 

Hi,

 

Visual or page filters - checked
Use IsPeerCompany in Visual Filter - done
Test the Measure Output: - Returns true only for the target company

I copied the meaure IsPeerCompany formula to a new measure and I am trying to decode which part of the formula is not giving the required result.

It fetches the correct SelectedCIK, correct SelectedBoardCode but not RelatedIndividuals. When I ran the measure till then and tried to output the result in a table, its giving me an error: MdxScript(Model) (410, 1) Calculation error in measure 'All Measures'[Testing]: A table of multiple values was supplied where a single value was expected.

Maybe this is the reason its not coming correct.

Hi @AyushAwasthi !
To resolve this issue,
Use CONTAINS, INTERSECT, or TREATAS to compare tables, not = :

Instead of this:
IF (RelatedIndividuals = CompanyIndividuals, TRUE, FALSE  )


Replace this dax :
IF (
NOT ISEMPTY(
INTERSECT(RelatedIndividuals, CompanyIndividuals)
),
TRUE,
FALSE
)

If you’re trying to extract one value, use SELECTEDVALUE ( ) only if you're sure the result is 1 row.

To debug further:

  • Temporarily output just COUNTROWS (RelatedIndividuals)in a card or table to confirm the number of rows being returned.

  • That’ll show if you need to use aggregation or iterate over multiple rows.

If you’d like to share the full IsPeerCompany formula here, I can help you rewrite the logic safely to avoid scalar-table conflicts.

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team.

 

Hi,

 

If I return COUNTROWS (RelatedIndividuals) it shows me the correct answer. I am using the same measure you provided i.e. ShowInPeerList.
I am not able to understand when thre ratio measure and the rank measure are working fine what is the issue for the table visual. The measure is showing 0 for all the other rows apart from thre target company. Am I missing something important here? Do I need to include any other fields?

Hi @AyushAwasthi  ,

Check:

Are peer companies present in the current visual context ?

Try adding company name+  ShowInPeerList  to a table without any slicers or filters, just to confirm if peer companies ever return 1.

Inspect what the logic compares inside ShowInPeerList :

If you're doing something like:

 
INTERSECT(RelatedIndividuals, VALUES(CompanyIndividuals[PersonID]))

make sure that for each peer company row, the correct list of PersinID is available.

 

Add debug columns temporarily :

Add a measure like:

DebugIndividuals = CONCATENATEX(VALUES(CompanyIndividuals[PersonID]), CompanyIndividuals[PersonID], ", ")

 

This helps see if the peer companies have overlapping individuals or not.

If you're still stuck, could you share - What the ShowInPeerList logic looks like. What tables are being used (Company table, Individuals, etc.).How you’re relating individuals to companies (many-to-many?)

That would help in pinpointing where the match logic may be falling short.

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team.

Hi @v-sshirivolu ,

 

I am using the same logic for ShowInPeerList what you shared:

ShowInPeerList =
VAR CurrentCIK = SELECTEDVALUE('Final Data'[CIK Code])
VAR SelectedCIKs = VALUES('List Table'[CIK Code])

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES('Match Table'[Board Code]),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES('Board Data'[Individual Id]),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES('Board Data'[Organization Id]),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES('Match Table'[CIK Code]),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
IF (CurrentCIK IN PeerCIKs, 1, 0)

The measure is resulting 1 only in a single case where the CIK in the Final Data is same as the SelectedCIKs. I also put the measure CurrentCIK for each row and it is showing correctly.

I also created custom tables using the code in the measure to show if the tables are being calculated properly.
SelectedBoardCodes fetches the correct code.
RelatedIndividuals fetches the correct IDs.
PeerOrgs also is correct.
PeerCIKs also generates correct CIK codes.
Only the last part is not able to calculate correctly. Which is all the more surprising as the separate measure you created for the average ratio which uses
RETURN CALCULATE (
AVERAGE ( 'Final Data'[Ratio] ),
'Final Data'[CIK Code] IN PeerCIKs
)

in the final line works correctly. Not able to understand if this can capture the correct set of companies why can't the ShowInPeerList measure.

Hi @AyushAwasthi 
Try These :

Option 1: Use CONTAINS instead of IN

ShowInPeerList =
VAR CurrentCIK = SELECTEDVALUE('Final Data'[CIK Code])
VAR SelectedCIKs = VALUES('List Table'[CIK Code])

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES('Match Table'[Board Code]),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES('Board Data'[Individual Id]),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES('Board Data'[Organization Id]),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES('Match Table'[CIK Code]),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
IF (CONTAINS(PeerCIKs, [CIK Code], CurrentCIK), 1, 0)

Option 2: Use COUNTROWS with FILTER

RETURN
IF (COUNTROWS(FILTER(PeerCIKs, [CIK Code] = CurrentCIK)) > 0, 1, 0)

Option 3: Force context transition with CALCULATE

RETURN
CALCULATE(IF(CurrentCIK IN VALUES('Match Table'[CIK Code]), 1, 0),
'Match Table'[Board Code] IN PeerOrgs
)

The key difference is that these approaches properly handle the table filtering in the context where it's being evaluated, rather than relying on the `IN` operator which can behave differently in measure evaluation contexts.

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team.

Hi,

 

Unfortunately none of the above ways have worked. If I don't use this measure, all the companies show up but when I put this measure in the filters on this visual field, only the slicer selected company comes up.

The rank card visual works fine and is counting 5 companies. At this point have no idea how to solve this.

Hi @AyushAwasthi ,
Try any of these alternatives:

Option 1: Use CONTAINS Instead of  IN
IF (CONTAINS(PeerCIKs, 'Match Table'[CIK Code], CurrentCIK), 1, 0)

Option 2: Use  COUNTROWS with FILTER
IF (
COUNTROWS(
FILTER(PeerCIKs, 'Match Table'[CIK Code] = CurrentCIK)
) > 0,
1,
0
)

Option 3: Force Context Transition Using CALCULATE 
CALCULATE(
IF (
CurrentCIK IN VALUES('Match Table'[CIK Code]), 1, 0
),
'Match Table'[Board Code] IN PeerOrgs
)



If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team.

 

Hi,

 

I tried all this but the result was still the same. But I figured out what was wrong. The filter context was being carried along all the tables that we were creating in the measure.

 

So adding REMOVEFILTERS to all the calculated tables resolved the issue. Thank you so much for all the help.

Hi,

 

I tried all this but the result was still the same. But I figured out what was wrong. The filter context was being carried along all the tables that we were creating in the measure.

 

So adding REMOVEFILTERS to all the calculated tables resolved the issue. Thank you so much for all the help.

Hi @AyushAwasthi ,
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team.

 
AyushAwasthi
Helper I
Helper I

Hi All,

 

I will just add my tables here as there is no option for me to add the pbix file.

 

Final Data:

Company Name CIK Code Ratio

Alpha Innovations0011.23
Beta Solutions0022.45
Gamma Technologies0033.67
Delta Dynamics0044.89
Epsilon Enterprises0055.12
Zeta Systems0066.34
Eta Consulting0077.56
Theta Industries0088.78
Iota Ventures0099.90
Kappa Holdings01010.11

 

List Table is the just the Company and CIK Code from the Final Table.

Match Table

 

Company Name CIK Code Board Company Board Code

Alpha Innovations001Alpha Inno22132
Beta Solutions002Beta S1231
Gamma Technologies003Gamma Subs214
Delta Dynamics004Deltex46
Epsilon Enterprises005Epso Ipso4646
Zeta Systems006ZeD One346364
Eta Consulting007Etas3434
Theta Industries008Thetos2342
Iota Ventures009Impex23423
Kappa Holdings010Kapri34534

 

Board Data:

Individual Name Individual Id Organization Name Organization Id

John SmithBD001Alpha Inno22132
John SmithBD001Beta S1231
Emily JohnsonBD002Gamma Subs214
Emily JohnsonBD002Deltex46
Michael BrownBD003Epso Ipso4646
Sarah DavisBD004ZeD One346364
David WilsonBD005Etas3434
Jessica GarciaBD006Thetos2342
Daniel MartinezBD007Impex23423
Laura RodriguezBD008Kapri34534
James LeeBD009Alpha Inno22132
Maria HernandezBD010Beta S1231
John SmithBD001Gamma Subs214
Emily JohnsonBD002Epso Ipso4646
James LeeBD009ZeD One346364
James LeeBD009Gamma Subs214


Now suppose someone selects the company Alpha Innovations in slicer from the List Table. The result table should look like:

CompanyCIK CodeBoard MemberRatio
Alpha Innovations001All1.23
Beta Solutions002John Smith2.45
Gamma Technologies003John Smith
James Lee
3.67
Zeta Systems006James Lee6.34

 
The card visual should show the average 3.42 and another card visual should show "4/4" (4th out of 4 companies when sorted by ratio).

 

I know the data is complex. Thanks in advance!

Hi @AyushAwasthi ,

Try these steps-

Create Measures

AveragePeerRatio =
VAR SelectedCIKs =
VALUES ( 'List Table'[CIK Code] )

 

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES ( 'Match Table'[Board Code] ),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES ( 'Board Data'[Individual Id] ),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES ( 'Board Data'[Organization Id] ),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES ( 'Match Table'[CIK Code] ),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
CALCULATE (
AVERAGE ( 'Final Data'[Ratio] ),
'Final Data'[CIK Code] IN PeerCIKs
)


For PeerCompanyRank :

PeerCompanyRank =
VAR SelectedCIKs =
VALUES ( 'List Table'[CIK Code] )

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES ( 'Match Table'[Board Code] ),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES ( 'Board Data'[Individual Id] ),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES ( 'Board Data'[Organization Id] ),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES ( 'Match Table'[CIK Code] ),
'Match Table'[Board Code] IN PeerOrgs
)

VAR SelectedRatio =
CALCULATE (
MAX ( 'Final Data'[Ratio] ),
'Final Data'[CIK Code] IN SelectedCIKs
)

VAR PeerTable =
FILTER (
'Final Data',
'Final Data'[CIK Code] IN PeerCIKs
)

VAR RankedTable =
ADDCOLUMNS (
PeerTable,
"Rank", RANKX ( PeerTable, [Ratio], , DESC )
)

VAR MyRank =
MAXX (
FILTER ( RankedTable, [CIK Code] IN SelectedCIKs ),
[Rank]
)

VAR TotalPeers = COUNTROWS ( PeerTable )

RETURN
FORMAT ( MyRank, "0" ) & "/" & FORMAT ( TotalPeers, "0" )



Card Visuals

1. Card for AveragePeerRatio.

  • Add a Card visual.

  • Set the Value to AveragePeerRatio.

    .

2. Card for PeerCompanyRank.

  • Add another Card visual.

  • Set the Value to PeerCompanyRank.

 Add a Table Visual

  1. Add these fields from Final data :

    • Company 

    • CIK code

Apply the Measure as a Filter

  1. With the table visual selected, go to the Filters pane on the right.

  2. Locate your new measure ShoqInPeerList.

  3. Drag ShowInPeerList into "Filters on this visual".

  4. Change the filter condition to:

    • "is"

    • "1"

 

Measure -  ShowInPeerList =
VAR SelectedCIKs =
VALUES ( 'List Table'[CIK Code] )

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES ( 'Match Table'[Board Code] ),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES ( 'Board Data'[Individual Id] ),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES ( 'Board Data'[Organization Id] ),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES ( 'Match Table'[CIK Code] ),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
IF ( 'Final Data'[CIK Code] IN PeerCIKs, 1, 0 )



If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

Find the attached pbix file for your reference.

Best Regards,
Sreeteja.
Community Support Team.

The last line gives an error for the measure ShowInPeerList:

A single value for column 'CIK Code' in table 'Final Data' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

Hi @AyushAwasthi ,

Replace it with this DAX :


ShowInPeerList =
VAR CurrentCIK = SELECTEDVALUE('Final Data'[CIK Code])
VAR SelectedCIKs = VALUES('List Table'[CIK Code])

VAR SelectedBoardCodes =
CALCULATETABLE (
VALUES('Match Table'[Board Code]),
'Match Table'[CIK Code] IN SelectedCIKs
)

VAR RelatedIndividuals =
CALCULATETABLE (
VALUES('Board Data'[Individual Id]),
'Board Data'[Organization Id] IN SelectedBoardCodes
)

VAR PeerOrgs =
CALCULATETABLE (
VALUES('Board Data'[Organization Id]),
'Board Data'[Individual Id] IN RelatedIndividuals
)

VAR PeerCIKs =
CALCULATETABLE (
VALUES('Match Table'[CIK Code]),
'Match Table'[Board Code] IN PeerOrgs
)

RETURN
IF (CurrentCIK IN PeerCIKs, 1, 0)


If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

Find the above attached pbix file for your reference.

Best Regards,
Sreeteja.
Community Support Team.

Tried doing that. It results only the company selected in the slicer. Rest of the measures are working fine.

v-sshirivolu
Community Support
Community Support

Hi @AyushAwasthi 
Thanks for reaching out to the Microsoft fabric community forum.


Try this steps -

Create a Measure for Selected Company :


Selected Company = SELECTEDVALUE('List Table'[Company])


Create a Measure to Identify Peer Companies :

Is Peer Company =
VAR TargetCompany = [Selected Company]
VAR TargetIndividuals =
CALCULATETABLE (
VALUES ( 'Match Table'[Individual ID] ),
'Match Table'[Company] = TargetCompany
)
VAR CurrentCompanyIndividuals =
CALCULATETABLE (
VALUES ( 'Match Table'[Individual ID] ),
'Match Table'[Company] = MAX('Final Data'[Company])
)
VAR SharedIndividuals =
INTERSECT ( TargetIndividuals, CurrentCompanyIndividuals )
RETURN
IF ( COUNTROWS(SharedIndividuals) > 0, 1, 0 )


Create Measure for Average Ratio of Peer Companies :

Avg Ratio of Peers =

CALCULATE (
AVERAGE ( 'Final Data'[Ratio] ),
FILTER (
'Final Data',
[Is Peer Company] = 1
)
)

Create Rank of Selected Company Among Peers :

Rank of Selected Company =
VAR TargetCompany = [Selected Company]
VAR PeerCompanies =
FILTER (
'Final Data',
[Is Peer Company] = 1
)
RETURN
RANKX (
PeerCompanies,
CALCULATE(SELECTEDVALUE('Final Data'[Ratio])),
,
DESC,
DENSE
)

Count Number of Peer Companies :

Peer Company Count =
CALCULATE (
DISTINCTCOUNT('Final Data'[Company]),
FILTER (
'Final Data',
[Is Peer Company] = 1
)
)

How Rank as a Text (e.g., 3/5) :

Rank Text =
VAR RankVal = [Rank of Selected Company]
VAR Total = [Peer Company Count]
RETURN
FORMAT ( RankVal, "0" ) & "/" & FORMAT ( Total, "0" )

Find attached Pbix file for your reference.

 

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

Best Regards,
Sreeteja.
Community Support Team 

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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