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

Repeat every value for each id

Hi,

 

Is there a way to easily convert a table to list all values for each id?

 

This is the solution I'm looking for:

Julkku_0-1606211651099.png

 

Thank you in advance!

 

Julia

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

Hi @Anonymous ,

 

Please following these steps:

 

1. Add a column whose value is 1 and a column which group ID and Type in table:

Value = 1 
IDType =
[ID] & [Type]

11.26.2.1.PNG

 

2. Create a calculated table using the following formula:

Table 2 =
VAR _tab =
    ADDCOLUMNS (
        CROSSJOIN ( ALL ( 'Table'[ID] ), ALL ( 'Table'[Type] ) ),
        "IDType", [ID] & [Type]
    )
RETURN
    ADDCOLUMNS (
        _tab,
        "Re",
            VAR _val =
                LOOKUPVALUE ( 'Table'[Value], 'Table'[IDType], [IDType] )
            RETURN
                IF ( _val = BLANK (), 0, _val )
    )

My final output looks like this:

11.26.2.2.PNG

 

Here is the pbix file.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @v-eqin-msft ,

 

Let me try again. The filtration is working fine with a normal bar chart but I need to present the results in a 100 stacked bar chart. I'd like to show statistics over people with "Oranges", but somehow the visualization is not capable to make any difference between 1 and 0. As every id is having every fruit listed, the visualization is showing same result no matter what fruit has been selected. 

 

I'd like "Oranges" to be 3, not the total of 5.

Julkku_0-1606987025524.png

The filtration works as wanted when filtering yes = 1 but this way the visualization is not showing the relative percentage which is very critical in this report. 

Julkku_1-1606987138835.png

The data is structured like this:

Julkku_2-1606988094882.png

 

You can download the pbix here: 

https://drive.google.com/drive/folders/1LNfBv3rOuk2giddLlsYhtPcCF75k9kND?usp=sharing

 

 

v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

I'm a little confused with your requirement...

 

12.1.5.1.gif

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @v-eqin-msft,

 

Another problem concerning the vizualisation came up. Your solution is presenting the data as I want but there must be something wrong with the filtration. No matter if I choose "bananas", "apples" or "oranges", other graphs present same results. I'm wondering if this has something to do with the fact that every id has all the three categories listed. I can't figure out how to change the vizualisation to filter only the ones that have value 1 in that particular category. When filtering other graphs, the fruit vizualisation changes normally.

 

Julia

Anonymous
Not applicable

Thank you @amitchandak and @v-eqin-msft for your guidance!

Evenlyn's solution was the one I was looking for.

 

Have a good day!

 

Julia

v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please following these steps:

 

1. Add a column whose value is 1 and a column which group ID and Type in table:

Value = 1 
IDType =
[ID] & [Type]

11.26.2.1.PNG

 

2. Create a calculated table using the following formula:

Table 2 =
VAR _tab =
    ADDCOLUMNS (
        CROSSJOIN ( ALL ( 'Table'[ID] ), ALL ( 'Table'[Type] ) ),
        "IDType", [ID] & [Type]
    )
RETURN
    ADDCOLUMNS (
        _tab,
        "Re",
            VAR _val =
                LOOKUPVALUE ( 'Table'[Value], 'Table'[IDType], [IDType] )
            RETURN
                IF ( _val = BLANK (), 0, _val )
    )

My final output looks like this:

11.26.2.2.PNG

 

Here is the pbix file.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

amitchandak
Super User
Super User

@Anonymous , You can create using

crossjoin(all(table[id]), Table(Name))

 

but to get 1, 0 more stuff is needed

like -union(addcolumns(Table, "status", 1), addcolumns(except(crossjoin(all(table[id]), Table(Name)), Table), "status", 0))

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.