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
vj123456
New Member

DAX - Index

Hi Team,

how to get the index number like this in calculated column using DAX.

I don't need Power Query solution, RANKX also.

the order of coutry should change

 

CountryIndex
Canada1
France2
Germany3
USA4
Bermuda5
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @vj123456 ,

 

You could create a calculated table.

DAX Indexed Table = 
    VAR __SourceTable = 'Table'
    VAR __Count = COUNTROWS(__SourceTable)
    VAR __SortText = CONCATENATEX(__SourceTable,[Country],"|")
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1,__Count,1),
            "Country",PATHITEM(__SortText,[Value],TEXT)
        )
RETURN
    __Table

vstephenmsft_0-1671604352473.png

Reference:

The Mythical DAX Index - Microsoft Power BI Community

 

Best Regards,

Stephen Tao

 

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

1 REPLY 1
v-stephen-msft
Community Support
Community Support

Hi @vj123456 ,

 

You could create a calculated table.

DAX Indexed Table = 
    VAR __SourceTable = 'Table'
    VAR __Count = COUNTROWS(__SourceTable)
    VAR __SortText = CONCATENATEX(__SourceTable,[Country],"|")
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1,__Count,1),
            "Country",PATHITEM(__SortText,[Value],TEXT)
        )
RETURN
    __Table

vstephenmsft_0-1671604352473.png

Reference:

The Mythical DAX Index - Microsoft Power BI Community

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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