Forum Discussion

danishwahab's avatar
danishwahab
Helper I
1 year ago
Solved

Xlookup from string

Dear All,

 

We are getting data in the below format where we are getting Raw value against each point and we need to identify it's state based on the metata in the State column coming in as a string value.

 

 

 

E.g. Point ID 1 should have occupancy state as Unoccupied where as Point ID 2 should have occupancy state as Occupied.

 

Expected Values

 

We are dealing with huge timeseries sensors data coming in every 15 minutes. Kindly provide us the logic DAX or Custom column logic which should have minimum performance impact. Also please suggest is this too bad to implement this in Power BI?

 

Thanks!

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Thank you uzuntasgokberk 

    Hi, danishwahab 

    You can do this in Power Query in Power BI. Here are the detailed steps:

    First I have the following dataset:

    To open the Advanced Editor:

    Copy the following M code into the Advanced Editor:

    ExtractText = Table.AddColumn(#"Changed Type", "Extracted Text", each Text.BetweenDelimiters(_[State],Text.From( _[Raw Data Value]) & "=",";"))

    The results are as follows:

    I have uploaded the PBIX file I used for this post below.

     

    Best Regards

    Jianpeng Li

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

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you uzuntasgokberk 

    Hi, danishwahab 

    You can do this in Power Query in Power BI. Here are the detailed steps:

    First I have the following dataset:

    To open the Advanced Editor:

    Copy the following M code into the Advanced Editor:

    ExtractText = Table.AddColumn(#"Changed Type", "Extracted Text", each Text.BetweenDelimiters(_[State],Text.From( _[Raw Data Value]) & "=",";"))

    The results are as follows:

    I have uploaded the PBIX file I used for this post below.

     

    Best Regards

    Jianpeng Li

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

    • danishwahab's avatar
      danishwahab
      Helper I

      Thank you Anonymous ,

       

      This worked perfectly as expected. Thanks for all your efforts and help in this. 

       

      Thanks!

  • Hello danishwahab,

     

    That would be better make a relationship Instead of writing a dax code f the perfomance better for you.

     

    Kind Regards,
    Gökberk Uzuntaş

    📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

    🔗 Stay Connected:
    📘 Medium |
    📺 YouTube |
    💼 LinkedIn |
    📷 Instagram |
    🐦 X |
    👽 Reddit |
    🌐 Website |
    🎵 TikTok |

     

    • danishwahab's avatar
      danishwahab
      Helper I

      Thanks uzuntasgokberk  for your response.
      For this how can we convert this to a table as the metadata is in string format with multiple values in a single column. As per my understanding we have to create a separate table status value in each row against each Point ID.

      • uzuntasgokberk's avatar
        uzuntasgokberk
        Super User

        Hello danishwahab,

        You can use Power Query(Transform Data), you can duplicate the fact table or referance and select columns that neccesary and remove duplicates. Make sure your created table has unique rows. Close & Apply and make relationship 1 to Many.

        Kind Regards,
        Gökberk Uzuntaş

        📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

        🔗 Stay Connected:
        📘 Medium |
        📺 YouTube |
        💼 LinkedIn |
        📷 Instagram |
        🐦 X |
        👽 Reddit |
        🌐 Website |
        🎵 TikTok |