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
ecalzavara
Helper II
Helper II

How to find valid values based on multiple tables

Hi guys,

I use this forum so much and I have almost found the answer I am after... Except for this one.

 

I have a table with:

  • attributes name
  • attributes values
  • name of the valid-values reference table
  • name of the specific valid-values column (if exists)

 

The first table below is basically my raw data:

AttributesValueData validationSpecific?
Num11TableNumTN_C1
Num22TableNumTN_C1
Num33TableNumTN_C1
Text14TableTxtTT_C1
Text25TableTxtTT_C1
Text3aTableTxtTT_C1
Num4bTableNum 
Num58TableNum 
Text49TableTxt 

 

The third column specifies another table name where to find the only possible valid values, being:

TableNum:

TN_C1TN_C2
1

one

2two
3three
4four
5five
6six
7seven
8eight
9nine
10ten

and

TableTxt:

TT_C1
a
b
c
d
e
f

 

If we want to make it more complex, the fourth column in the raw data table specifies which column to look for in the valid values table.

 

I am trying to get a calculated column (I believe?) that reports TRUE if the values are present in the specific reference table/column, otherwise FALSE.

 

I managed to get close to what I want by creating a calculate column for:

ValidNum? = if(all_data[Value] IN DISTINCT(TableNum[TN_C1]),"Valid","Invalid")
 
What I need now, is to generalise this statement and not to have to specify/hard-code the name of the valid-values table, but making the formula understand that the valid-values table name is in the original table in the (third) column named "Data validation".
 
AttributesValueData validationSpecific?Valid
Num11TableNumTN_C1TRUE
Num22TableNumTN_C1

TRUE

Num33TableNumTN_C1TRUE
Text14TableTxtTT_C1FALSE
Text25TableTxtTT_C1FALSE
Text3aTableTxtTT_C1TRUE
Num4bTableNum FALSE
Num58TableNum TRUE
Text49TableTxt FALSE
I think my explanation can be a bit cumbersome but the solution shouldn't be so difficult... just I can't get there.
 
Thank you so much in advance!
8 REPLIES 8
ryan_mayu
Super User
Super User

@ecalzavara 

is this what you want?

Column = if(LEFT('Table'[attributes],3)="Num" && ISNUMBER('Table'[Value]),TRUE(),FALSE())




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for your quick answer @ryan_mayu . Unfortunately is not that easy. I am not only trying to find numbers but to associate the raw data with possibly many different tables containing a set of values, which make my data VALID or INVALID depending if the value on a specific row [Value] is found in the specified table [Data validation] (and, as next step, to be found in a specific column in that [Data validation] table, explicit in [Specific?] column.

 

Thank you for your go, really appreciated!

@ecalzavara 

sry, not clear about your request. so your raw data only contains two columns? How you get the third column and forth column?

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nope,

My raw data (in the example provided) contains 4 columns (the formatting on the forum is not the best):


|   Attributes   |   Value   |   Data validation     Specific?  |

 

 

The Data validation column (and, if present, the Specific? one) defines the name of the table where the valid set of values are to be found for that specific attribute.

 

I hope this clarifies it.

Thanks

@ecalzavara 

what do you want now? check if value exists in the data validation table?

 

Attributes Value Data validation Specific? Valid
Num1 1 TableNum TN_C1 TRUE
Num2 2 TableNum TN_C1

TRUE

Num3 3 TableNum TN_C1 TRUE
Text1 4 TableTxt TT_C1 FALSE
Text2 5 TableTxt TT_C1 FALSE
Text3 a TableTxt TT_C1 TRUE
Num4 b TableNum   FALSE
Num5 8 TableNum   TRUE
Text4 9 TableTxt   FALSE

 

value 1 from TableNum, then true? value 9 not from TableTxt then FALSE?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

"value 1 from TableNum, then true? value 9 not from TableTxt then FALSE?"

 

Correct

@Anonymous @ecalzavara 

pls see the attachment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you @ryan_mayu .

This relies on manually define the variables, right?

ecwillow_0-1629175316572.png

 

So, if I have 30 different Data Validation table I'd need to define the variables one by one?

What I am trying to get is that the definition of the validation tables are in the raw data (which I have) and that this specifies where to go and find the valid values. I am trying something like the IF(...IN DISTINCT()) approach, but that moves away from having to hard-code (variables or many different, possibly hundreads of tables) in the DAX.  As I have already everything defined, either in the raw data or in the validation table, I would like to move away from the variables (unless they can be parametrised and created automatically from information in the raw data table).

 

Thank you

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.