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
CoTheiss
Frequent Visitor

Data Mapping based on other table's field name

Hi Community ! 

As my BI-experiences are more with other tools than PowerBI, I am struggling on this one as I think it should work somehow:

 

I do have two tables:

Data

DataID Column2 Column3 Column4
1Text123<null>Text789
2<null>Text456Text789

 

Scoring

ScoringID DataColumn Score
1Column210
2Column35
3Column420

 

My issue:

I want to apply a scoring for DataQuality for one of my tables.

Meaning: I have a defined Scoring table applying a score per specific column that should be applied if the datafield is not null.

Based on the example posted, DataID 1 will have a score of 30, while DataID 2 should have a scoring of 25.

So I at least think, that I need something like

if(Data.ColumnName() = [Scoring].[DataColumn], if(isnull([Data].[Column2]),0,1)*[Scoring].[DataColumn])  

 

However, I am stuck due to the lack of PowerBI knowledge as I do not know where exactly to apply and as well how to get this comparision with the field name.

 

Hope someone can help me out here 🙂

Also, if there are any other or built-in options to do this - very appreciated!

1 ACCEPTED SOLUTION
PawarNovil
Frequent Visitor

Hello @CoTheiss 

 

You can create a calculated column  in your Data Table as

Score =
IF('DataID'[Column1]=BLANK(),0,CALCULATE(sum(Score[Score]),FILTER(Score,Score[Datacolumn]="column1")))+         IF('DataID'[Column2]=BLANK(),0,CALCULATE(sum(Score[Score]),FILTER(Score,Score[Datacolumn]="column2")))+
      IF('DataID'[Column3]=BLANK(),0,CALCULATE(sum(Score[Score]),FILTER(Score,Score[Datacolumn]="column3")))
 

PawarNovil_0-1667993006188.png

--------------------------------------------------------------------------------------------------

Also you can achive this by unpivoting Data table col1, col2, col3 in advance editor.

PawarNovil_3-1667993962809.png

 

After that you need to merge data table and score table on column "Datacolumn". 

PawarNovil_1-1667993746912.png

After merging your Data table look like this, then you can aggregate the data or create measure to get your desired result.

PawarNovil_2-1667993835564.png

 

Regards,

Novil

If I answer your question, please mark my post as a solution.

 

View solution in original post

3 REPLIES 3
PawarNovil
Frequent Visitor

Hello @CoTheiss 

 

You can create a calculated column  in your Data Table as

Score =
IF('DataID'[Column1]=BLANK(),0,CALCULATE(sum(Score[Score]),FILTER(Score,Score[Datacolumn]="column1")))+         IF('DataID'[Column2]=BLANK(),0,CALCULATE(sum(Score[Score]),FILTER(Score,Score[Datacolumn]="column2")))+
      IF('DataID'[Column3]=BLANK(),0,CALCULATE(sum(Score[Score]),FILTER(Score,Score[Datacolumn]="column3")))
 

PawarNovil_0-1667993006188.png

--------------------------------------------------------------------------------------------------

Also you can achive this by unpivoting Data table col1, col2, col3 in advance editor.

PawarNovil_3-1667993962809.png

 

After that you need to merge data table and score table on column "Datacolumn". 

PawarNovil_1-1667993746912.png

After merging your Data table look like this, then you can aggregate the data or create measure to get your desired result.

PawarNovil_2-1667993835564.png

 

Regards,

Novil

If I answer your question, please mark my post as a solution.

 

Hi @PawarNovil 

I just tried the first approach with the calculated column and it works! 

 

I also learned, that having a datafield with len(Field)=0 does not neccessarily equals blank() - as I needed to adapt the formula to if('Data'[Column2]="",...) 

 

I did not try the second approach (yet) as the first one was sufficient already (and my dataset is quite wide and long) 

BeaBF
Impactful Individual
Impactful Individual

@CoTheiss Looks to me like this is only possible when you transpose Table Data:

BeaBF_0-1667991372250.png

using DataColumn as key between Data Table and Scoring Table.

 

BBF

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.