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
Anonymous
Not applicable

Building a new table using variant specific ratings

Hello,

 

I have data scattered around in tables and would like to make one table out of it so that I can use that one for further calculations, filtering and visualisation. Simplified I have three tables like this:

- one table containing the master data

MasterScores

item

score

A

1

B

5

C

4

D

6

E

2

F

3

G

4

 

- one table containing variant specific data:

VariantScores

variant

item

new score

VAR1

A

2

VAR1

F

2

VAR1

G

3

VAR2

B

4

VAR2

D

5

VAR3

C

3

VAR3

D

7

VAR3

E

3

 

- and one table telling me which item/row to exclude from each variant:

ExcludedFromVariant

 

variant

item

VAR1

B

VAR1

C

VAR2

A

VAR3

A

VAR3

F

 

I would now like to make one new table out of it that looks like:

NewTable

variant

item

score

MASTER

A

1

MASTER

B

5

MASTER

C

4

MASTER

D

6

MASTER

E

2

MASTER

F

3

MASTER

G

4

VAR1

A

2

VAR1

D

6

VAR1

E

2

VAR1

F

2

VAR1

G

3

VAR2

B

4

VAR2

C

4

VAR2

D

5

VAR2

E

2

VAR2

F

3

VAR2

G

4

VAR3

B

5

VAR3

C

3

VAR3

D

7

VAR3

E

3

VAR3

G

4

 

And to make it even more difficult: I don't know upfront how many variants I have.

Does anyone have an idea?

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

@Anonymous,

 

You may refer to the DAX below that adds a calculated table 

Table =
VAR t =
    UNION (
        ROW ( "variant", "MASTER" ),
        DISTINCT (
            UNION (
                VALUES ( VariantScores[variant] ),
                VALUES ( ExcludedFromVariant[variant] )
            )
        )
    )
RETURN
    ADDCOLUMNS (
        GENERATEALL (
            t,
            FILTER (
                MasterScores,
                NOT CONTAINS (
                    ExcludedFromVariant,
                    ExcludedFromVariant[variant], [variant],
                    ExcludedFromVariant[item], MasterScores[item]
                )
            )
        ),
        "new score", LOOKUPVALUE (
            VariantScores[new score],
            VariantScores[variant], [variant],
            VariantScores[item], MasterScores[item]
        )
    )
Community Support Team _ Sam Zha
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-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may refer to the DAX below that adds a calculated table 

Table =
VAR t =
    UNION (
        ROW ( "variant", "MASTER" ),
        DISTINCT (
            UNION (
                VALUES ( VariantScores[variant] ),
                VALUES ( ExcludedFromVariant[variant] )
            )
        )
    )
RETURN
    ADDCOLUMNS (
        GENERATEALL (
            t,
            FILTER (
                MasterScores,
                NOT CONTAINS (
                    ExcludedFromVariant,
                    ExcludedFromVariant[variant], [variant],
                    ExcludedFromVariant[item], MasterScores[item]
                )
            )
        ),
        "new score", LOOKUPVALUE (
            VariantScores[new score],
            VariantScores[variant], [variant],
            VariantScores[item], MasterScores[item]
        )
    )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.