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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
vpsoini
Helper I
Helper I

Freetext data mapping into pre-defined values or "others"

Hello.

 

I'm trying to list models of sold units into a table, but the issue is that model name/number is a freetext field, so sometimes values are not excatly correct.  I have ledger table, where item sales are listed with columns:

 

Date/Model/Quantity/Price  (below samples with Tesla examples) , where Model column is not a drop-down with pre-defined values, but freetext field

 

DateModelQuantityAmount
21.02.2023Model 3150000
19.02.2023Model X2200000
16.02.20233150000
02.02.2023S1100000
24.01.2023X-model1100000
15.01.2023big sedan1125000
13.1.2023Mdel 3155000

 

And another "helper table" where I have tried to uniform some of the manually entered "wrong" values into right models / model series. This table has e.g. columns

 

Original model/uniformed model/model series  (once again with Tesla examples)

Original modelUniformed ModelSeries
Model 3Model 33
3-modelModel 33
3Model 33
Model XModel XX
X-modelModel XX
XModel XX
Model SModel SS
S-modelModel SS
SModel SS

 

These 2 tables are connected with Model - Original Model link and I'm using "uniformed model" as my key in the table visual.

 

Since the model in the sales ledger table is freetext, users can have whatever kind of typos etc in that field and if I don't have that corresponding typo defined in the helper table, that value will not be calculated within that table. In my example ledger those 2 earliest values have model written incorreclty in a way, which is not defined in the helper table, so they would not be visual in my table

 

So the question is:  what would be the easiest way to define value "undefined" into the table visual, where all those model "typos" from ledger could be collected in order to get total sales values.  The example table visual could be e.g. total sum:

 

Uniformed modelSales
Model 3100000
Model S100000
Model X300000
undefined180000
Total680000

 

So how can I define something, that can be basically anything (but those pre-defined values), into one group named "undefined" ?

 

Thanks a lot for your solution proposals 😊

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @vpsoini ,

 

Here are the steps you can follow:

1. Create calculated column.

Flag =
var _1=
DISTINCT(
SELECTCOLUMNS(
    'Table2',"Uniformed Model","undefined"))
var _2=
DISTINCT('Table2'[Uniformed Model])
return
UNION(
    _2,_1)

vyangliumsft_0-1677120295400.png

2. Create calculated table.

 

Sales =
var _groupcolumn =
SELECTCOLUMNS(
    FILTER('Table2','Table2'[Uniformed Model]=EARLIER('Flag'[Uniformed Model])),
    "1",
    [Original model])
var _allcolumn=
SELECTCOLUMNS(
   'Table2',
    "1",
    [Original model])
var _sum=
SUMX(
    FILTER(ALL(Table1),
    'Table1'[Model] in _groupcolumn),[Amount])
return
 IF(
     _sum = BLANK(),
    SUMX(
    FILTER(ALL(Table1),
    NOT('Table1'[Model]) in _allcolumn),[Amount]),_sum)

vyangliumsft_1-1677120295401.png

3. Result:

vyangliumsft_2-1677120295404.png

 

Best Regards,

Liu Yang

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

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @vpsoini ,

 

Here are the steps you can follow:

1. Create calculated column.

Flag =
var _1=
DISTINCT(
SELECTCOLUMNS(
    'Table2',"Uniformed Model","undefined"))
var _2=
DISTINCT('Table2'[Uniformed Model])
return
UNION(
    _2,_1)

vyangliumsft_0-1677120295400.png

2. Create calculated table.

 

Sales =
var _groupcolumn =
SELECTCOLUMNS(
    FILTER('Table2','Table2'[Uniformed Model]=EARLIER('Flag'[Uniformed Model])),
    "1",
    [Original model])
var _allcolumn=
SELECTCOLUMNS(
   'Table2',
    "1",
    [Original model])
var _sum=
SUMX(
    FILTER(ALL(Table1),
    'Table1'[Model] in _groupcolumn),[Amount])
return
 IF(
     _sum = BLANK(),
    SUMX(
    FILTER(ALL(Table1),
    NOT('Table1'[Model]) in _allcolumn),[Amount]),_sum)

vyangliumsft_1-1677120295401.png

3. Result:

vyangliumsft_2-1677120295404.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.