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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Saul_K
Regular Visitor

Finding unique / distinct values from a row

I have a table like this  : I wanted to know the number of storage connected to VM ( Datastore name contains the storage name )

Server NameDatastores.1.1Datastores.2.1Datastores.3.1Datastores.4.1Datastores.5.1Datastores.6.1Datastores.7.1Datastores.8.1
VM1PureStorage05PureStorage05PureStorage05PureStorage02PureStorage02PureStorage02PureStorage05PureStorage05
VM2PureStorage05PureStorage02PureStorage05PureStorage05PureStorage05PureStorage05PureStorage02PureStorage02
VM3InfiniStorage09PureStorage06PureStorage06PureStorage06PureStorage01PureStorage01PureStorage06PureStorage06

 

 

I am looking for an output like this  :

Server_NameNo_of_Storage_connected StorageArray
VM12PureStorage05 ,PureStorage02
VM22PureStorage05 ,PureStorage02
VM33InfiniStorage09,PureStorage06,PureStorage01

 

 

Could you please help me to find a way to do this  ?

@PowerBI 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Saul_K tweak the measure to filter out N/A:

 

Storage Count = 
VAR __Table = 
DISTINCT ( 
    UNION ( 
        VALUES ( 'Storage'[Datastores.1.1] ),
        VALUES ( 'Storage'[Datastores.2.1] ),
        VALUES ( 'Storage'[Datastores.3.1] ),
        VALUES ( 'Storage'[Datastores.4.1] ),
        VALUES ( 'Storage'[Datastores.5.1] ),
        VALUES ( 'Storage'[Datastores.6.1] ),
        VALUES ( 'Storage'[Datastores.7.1] ),
        VALUES ( 'Storage'[Datastores.8.1] )
    )
)
RETURN
COUNTROWS ( FILTER ( __Table, [Datastores.1.1] <> "N/A" ) )


Storage Array = 
VAR __Table = 
DISTINCT ( 
    UNION ( 
        VALUES ( 'Storage'[Datastores.1.1] ),
        VALUES ( 'Storage'[Datastores.2.1] ),
        VALUES ( 'Storage'[Datastores.3.1] ),
        VALUES ( 'Storage'[Datastores.4.1] ),
        VALUES ( 'Storage'[Datastores.5.1] ),
        VALUES ( 'Storage'[Datastores.6.1] ),
        VALUES ( 'Storage'[Datastores.7.1] ),
        VALUES ( 'Storage'[Datastores.8.1] )
    )
)
RETURN
CONCATENATEX ( FILTER ( __Table, [Datastores.1.1] <> "N/A" ), [Datastores.1.1], "," )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@Saul_K tweak the measure to filter out N/A:

 

Storage Count = 
VAR __Table = 
DISTINCT ( 
    UNION ( 
        VALUES ( 'Storage'[Datastores.1.1] ),
        VALUES ( 'Storage'[Datastores.2.1] ),
        VALUES ( 'Storage'[Datastores.3.1] ),
        VALUES ( 'Storage'[Datastores.4.1] ),
        VALUES ( 'Storage'[Datastores.5.1] ),
        VALUES ( 'Storage'[Datastores.6.1] ),
        VALUES ( 'Storage'[Datastores.7.1] ),
        VALUES ( 'Storage'[Datastores.8.1] )
    )
)
RETURN
COUNTROWS ( FILTER ( __Table, [Datastores.1.1] <> "N/A" ) )


Storage Array = 
VAR __Table = 
DISTINCT ( 
    UNION ( 
        VALUES ( 'Storage'[Datastores.1.1] ),
        VALUES ( 'Storage'[Datastores.2.1] ),
        VALUES ( 'Storage'[Datastores.3.1] ),
        VALUES ( 'Storage'[Datastores.4.1] ),
        VALUES ( 'Storage'[Datastores.5.1] ),
        VALUES ( 'Storage'[Datastores.6.1] ),
        VALUES ( 'Storage'[Datastores.7.1] ),
        VALUES ( 'Storage'[Datastores.8.1] )
    )
)
RETURN
CONCATENATEX ( FILTER ( __Table, [Datastores.1.1] <> "N/A" ), [Datastores.1.1], "," )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@ThxAlot that was my first recommendation in my reply.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

ThxAlot
Super User
Super User

CONFIG.pbix

 

Isn't it enough simple after you unpivot the table?

ThxAlot_0-1693655994237.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Thanks for the response.  I am very new to Powerbi and not good with the unpivot option, I will take a look. Thank you for the suggetion. 

parry2k
Super User
Super User

@Saul_K Usually you want unpivoted data but with the current structure, you can add the following two measures to get the result;

 

Storage Count = 
VAR __Table = 
DISTINCT ( 
    UNION ( 
        VALUES ( 'Storage'[Datastores.1.1] ),
        VALUES ( 'Storage'[Datastores.2.1] ),
        VALUES ( 'Storage'[Datastores.3.1] ),
        VALUES ( 'Storage'[Datastores.4.1] ),
        VALUES ( 'Storage'[Datastores.5.1] ),
        VALUES ( 'Storage'[Datastores.6.1] ),
        VALUES ( 'Storage'[Datastores.7.1] ),
        VALUES ( 'Storage'[Datastores.8.1] )
    )
)
RETURN
COUNTROWS ( __Table )


Storage Array = 
VAR __Table = 
DISTINCT ( 
    UNION ( 
        VALUES ( 'Storage'[Datastores.1.1] ),
        VALUES ( 'Storage'[Datastores.2.1] ),
        VALUES ( 'Storage'[Datastores.3.1] ),
        VALUES ( 'Storage'[Datastores.4.1] ),
        VALUES ( 'Storage'[Datastores.5.1] ),
        VALUES ( 'Storage'[Datastores.6.1] ),
        VALUES ( 'Storage'[Datastores.7.1] ),
        VALUES ( 'Storage'[Datastores.8.1] )
    )
)
RETURN
CONCATENATEX ( __Table, [Datastores.1.1], "," )

 

parry2k_0-1693596845479.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks a lot , that helps . I am very new to power bi and my questions may feel silly 🙂  I have one more ask,how we can ignore 'Null' / 'N/A' values when you run the above query ? I had null values before, but I changed  it to N/A. 

 

The below is the sample table. 

 

Saul_K_0-1693833050347.png

 

As there is N/A value in most of the row, it calculate that as a value and add it in to count and storage array output.

 

 

Server_NameNo_of_Storage_connected StorageArray
VM12PureStorage05 ,PureStorage02
VM23PureStorage05 ,PureStorage02,N/A
VM34InfiniStorage09,PureStorage06,PureStorage01,N/A

Saul_K_1-1693833284576.png

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.