Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How to control the bar chart by changing select list

Hi everyone,

 

Am looking for a way to control the value of a categorial feature in the bar chart by changing select list.

 

Details are as follows.

There are two tables (A&B) which is attached below. In Table A, there is ITEM A and B. In Table B, there is ITEM C1 and C2.

The bar chart is categorized by ITEM.

The value of ITEM A from Table A is shown in bar A. Value of ITEM B from Table A is shown in bar B.

At for C1 and C2 of Table B, which one is going to be shown in the categorial feature ITEM C in the bar chart, should be selectable.

If C1 is chosen, the value of ITEM C1 in Table B, which is 300, will be shown in the bar chart as C.

If C2 is chosen, the value of ITEM C2 in Table B, which is 400, will be shown in the bar chart as C.

 

Anyone with good idea?

If any further infomation is needed please feel free to contact.

Thank you very much.

  • There are many ways of doing this but the safest will be to have a disconnected reference table with Items A,B,C  and then create a measure that cacluates the value for each item.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

     

    Has Ibendlin's response solved your problem? If so, please accept his reply as the solution.
    If you still need more detailed steps, please refer below:
    1. Create a table containing ITEM ABC and do not create relationships with other tables.

    ITEMS = DATATABLE(
    "ITEM", STRING,
    {
    {"A"},
    {"B"},
    {"C"}
    }
    )


    2. Create a measure for each ITEM.

    ITEM A VALUE =
    IF(
    MAX(ITEMS[ITEM]) = "A",
    CALCULATE(SUM('Table A'[VALUE]), 'Table A'[ITEM] = "A"),
    BLANK()
    )
    ITEM B VALUE =
    IF(
    MAX(ITEMS[ITEM]) = "B",
    CALCULATE(SUM('Table A'[VALUE]), 'Table A'[ITEM] = "B"),
    BLANK()
    )
    ITEM C VALUE =
    IF(
    MAX(ITEMS[ITEM]) = "C",
    SWITCH(
    TRUE(),
    SELECTEDVALUE('Table B'[ITEM]) = "C1", CALCULATE(SUM('Table B'[VALUE]), 'Table B'[ITEM] = "C1"),
    SELECTEDVALUE('Table B'[ITEM]) = "C2", CALCULATE(SUM('Table B'[VALUE]), 'Table B'[ITEM] = "C2"),
    BLANK()
    ),
    BLANK()
    )


    3. Creating a slicer using the ITEM field of TABLE B. In the bar chart, the ITEM of the ITEM table is used as the Y-axis, and the measures of the three ITEMs are used as the X-axis.

     

    Best Regards,

    Jarvis Tang

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

3 Replies

  • There are many ways of doing this but the safest will be to have a disconnected reference table with Items A,B,C  and then create a measure that cacluates the value for each item.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Ibendlin,

      Thank you so much for your reply.

      Will try this way.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

         

        Has Ibendlin's response solved your problem? If so, please accept his reply as the solution.
        If you still need more detailed steps, please refer below:
        1. Create a table containing ITEM ABC and do not create relationships with other tables.

        ITEMS = DATATABLE(
        "ITEM", STRING,
        {
        {"A"},
        {"B"},
        {"C"}
        }
        )


        2. Create a measure for each ITEM.

        ITEM A VALUE =
        IF(
        MAX(ITEMS[ITEM]) = "A",
        CALCULATE(SUM('Table A'[VALUE]), 'Table A'[ITEM] = "A"),
        BLANK()
        )
        ITEM B VALUE =
        IF(
        MAX(ITEMS[ITEM]) = "B",
        CALCULATE(SUM('Table A'[VALUE]), 'Table A'[ITEM] = "B"),
        BLANK()
        )
        ITEM C VALUE =
        IF(
        MAX(ITEMS[ITEM]) = "C",
        SWITCH(
        TRUE(),
        SELECTEDVALUE('Table B'[ITEM]) = "C1", CALCULATE(SUM('Table B'[VALUE]), 'Table B'[ITEM] = "C1"),
        SELECTEDVALUE('Table B'[ITEM]) = "C2", CALCULATE(SUM('Table B'[VALUE]), 'Table B'[ITEM] = "C2"),
        BLANK()
        ),
        BLANK()
        )


        3. Creating a slicer using the ITEM field of TABLE B. In the bar chart, the ITEM of the ITEM table is used as the Y-axis, and the measures of the three ITEMs are used as the X-axis.

         

        Best Regards,

        Jarvis Tang

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