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
Anonymous
Not applicable

How to sequence a missing key value? - For example N/As should become Missing_N

Hello dear experts, 

 

I know this might raise some questions w.r.t data integrity, but I'm trying to understand the capabilities of Power BI, so please allow me to.

 

I have a problem where I don't have the "Ref Key" field, however, I have N/A (with duplicates) in the key column. So everytime I have to remove N/A to make some joins with Ref Key field.

 

jonnaamb_1-1598020987957.png

 

Instead, I wish to replace it with "Missing_N" where N is a counter. That means all the N/As should become sequenced - Missing_1, Missing_2, Missing_3 without affecting the existing Ref Key. Is this possible?

 

 

Kind regards,

Ambareesh.

 
 
 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @Anonymous,

I'd like to suggest you add an index column to your table at query edit side, then you can use the following calculated column to replace raw ref values:

Replaced Refkey =
IF (
    [Ref key] = BLANK (),
    " Missing_"
        & COUNTROWS (
            FILTER ( Table, [Ref key] = BLANK () && [Index] <= EARLIER ( [Index] ) )
        ),
    [Ref key]
)

Create Index Columns Using Power Query 
Regards.

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @Anonymous,

I'd like to suggest you add an index column to your table at query edit side, then you can use the following calculated column to replace raw ref values:

Replaced Refkey =
IF (
    [Ref key] = BLANK (),
    " Missing_"
        & COUNTROWS (
            FILTER ( Table, [Ref key] = BLANK () && [Index] <= EARLIER ( [Index] ) )
        ),
    [Ref key]
)

Create Index Columns Using Power Query 
Regards.

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , for that you need some incremental column

add index column

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

then try a new column like

" Missing_" & countx(filter(Table, [Ref key] = earlier([Ref Key])  && [Index] < earlier([Index]) , [Ref Key])

 

Anonymous
Not applicable

Dear @amitchandak ,

 

I tried the formula, but it throws an error. Kindly check again.

 

Expression.Error: The name 'CountX' wasn't recognized. Make sure it's spelled correctly.

 

Thanks,

Ambareesh

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.