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
SanketBhagwat
Solution Sage
Solution Sage

Need help with a scenario.

Need to add new column to Tab table - TabIndexParent.

  • If ParentTab is not 00000000-00000... then lookup ParentTab ID in Tab column and populate TabIndexParent column with TabIndex.
    • ie, see highlighted rows
      • in this example TabIndexParent would be populated = 1600 for all rows that have ParentTab = 5915D......
  • If ParentTab = 0000000-0000.... then populate TabIndexParent = TabIndex
    • 0000... means they have no parent, only 1 level. so we use TabIndex as TabIndexParent
  • ParentTabTabTabIndexTabIndexParent
    00000000-0000-0000-0000-0000000000000BBCFD72-2325-4D48-8D0B-A44463BB011D21002100
    00000000-0000-0000-0000-0000000000005915D9B3-1527-4B08-8819-96DF21C84B6B16001600
    6565A8D4-A939-430F-AEDC-4A7F85293B360F2CB553-0796-4DF0-99C2-2F5CF7F1EBBA30001000
    0F2CB553-0796-4DF0-99C2-2F5CF7F1EBBA6565A8D4-A939-430F-AEDC-4A7F85293B3610003000

     

@amitchandak @parry2k @selimovd  @Fowmy  Please help.

10 REPLIES 10
Aditya_Meshram
Solution Supplier
Solution Supplier

Hi @SanketBhagwat ,

you can use the following dax for the requirement 

 

TabIndexParentnew =
Switch('Table'[ParentTab],
"00000000-0000-0000-0000-000000000000",'Table'[TabIndex],
LOOKUPVALUE('Table'[TabIndex],'Table'[ParentTab],'Table'[Tab]
))
 
Regards,
Aditya

Hi @Aditya_Meshram .

My column doesn't contain unique values, so your DAX is not working and giving an error as "A table of multiple values was supplied where a single value was expected".

 

selimovd
Super User
Super User

Hey @SanketBhagwat ,

 

your description is very confusing.

Here what I understood:

- You want a new column

- The content should the content of ParentTab when ParentTab is not "00000000-0000-0000-0000-000000000000".

- When ParentTab is "00000000-0000-0000-0000-000000000000" you want the content of TabIndexParent

 

Did I get that right?

 

Best regards

Denis

1)When Parent Tab is "00000000-0000-0000-0000-000000000000",then it will directly return its correspondingTabIndexvalue.

 

2)When ParentTab is not equal to "00000000-0000-0000-0000-000000000000", then it will look for that ID
 in Tab column and return the 'TabIndex' for that 'Tab' column.

So suppose if I have 'ParentTab' value as 22525-272625-282827, then it will search that value in 'Tab' Column and return 'TabIndex' of that value in the new column.

For example, in the data which I provided, TabIndexParent is the new calculated column which we want to calculate.

So when ParentTab is "00000000-0000-0000-0000-000000000000",the new column is returning its corresponding TabIndex value which is 2100.

 

When ParentTab is "6565A8D4-A939-430F-AEDC-4A7F85293B36", it is searching for that value in 'Tab'

column and returning value as 1000.

 

Hope that will make things clear.

Same when ParentTab is "0F2CB553-0796-4DF0-99C2-2F5CF7F1EBBA", it is returning value as 3000.

Hey @SanketBhagwat ,

 

thank you for the explanation. Now I got what you need.

Please try the following calculated column:

TabIndexParent NEW =
VAR vParentTab = 'Tab Table'[ParentTab]
RETURN
    SWITCH(
        TRUE(),
        'Tab Table'[ParentTab] = "00000000-0000-0000-0000-000000000000", 'Tab Table'[TabIndex],
        CALCULATE(
            MAX( 'Tab Table'[TabIndex] ),
            ALL( 'Tab Table' ),
            'Tab Table'[Tab] = vParentTab
        )
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi @selimovd .

Thanks for your reply.

That DAX worked, but didn't gave the perfect output.

Appreciate your help.

 

 

Hey @SanketBhagwat ,

 

and what exactly is still wrong?

Give me some feedback, then I can change the formula.

 

Best regards

Denis

Hi @selimovd .

I can't share the data, so I took some sample data and posted that in this blog.

For some Tab ID's there are multiple TabIndex values.

 

If we use MAX function to get the maximum value out of those, then we are getting wrong output.

We are getting correct output for  "00000000-0000-0000-0000-000000000000",but not for other values.

 

I think wee will need to create a custom Key column by making use of any other column to bifuracte.

 

For example, we can make use of any ID column in the table and create a key column using  Tab ID and ID from that column and then use LOOKUPVALUE function to search that value in the Key column.

 

Regards,

Sanket Bhagwat

 

Hey @SanketBhagwat ,

 

when you have multiple Tabindex values, how do you know which one is the correct one?

If there is no logic to do the right selection, you have to find another criteria to get a correct match.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

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.

Top Solution Authors