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
olimilo
Responsive Resident
Responsive Resident

Load the values of a different column based on a filter (ie: dynamic column)

I have a custom table Selection with the following values in the [Options] column: "Country", "Region", "City"; and a calculated column 'Data'[Selection] whose values will depend on which value the user selects from the 'Selection'[Options] column.

 

If I select "Country", it would populate the calculated column with the values from Data[Country]; select "Region" and populate it with Data[Region] values and so on.

 

So far, all that I have seen would require me to pivot my table. Is there a way to not do a pivot? Basically, what I would like to do is similar to the one below (doesn't work):

 

Selection = 
    IF(HASONEVALUE('Selection'[Options]),
        SWITCH(
            VALUES('Selection'[Options]),
            "Country", [Country]
            "Region", [Region]
            "City", [City]
        )
    )

 

 

1 ACCEPTED SOLUTION

Hi @olimilo ,

By my tests and research, we cannot achieve your desired output directly with measures.

If you do not want to unpivot your original Data Table, you could create a calculated table as a  workaroud.

Table =
UNION (
    SELECTCOLUMNS (
        'Data Table',
        "orderid", [Work OrderID],
        "type", "country",
        "value", [Country]
    ),
    SELECTCOLUMNS (
        'Data Table',
        "orderid", [Work OrderID],
        "type", "Region",
        "value", [Region]
    ),
    SELECTCOLUMNS (
        'Data Table',
        "orderid", [Work OrderID],
        "type", "city",
        "value", [City]
    )
)

Here is the output.

Capture.PNG

More details, you could refer to my attachment.

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

4 REPLIES 4
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @olimilo ,

More details will be much helpful.

Do you have more than one table or only the table?

If it is convenient, could you share the data sample and your desired output so that we could have a test on it?

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-piga-msft 

This is what the sample data looks like:

 

2019-09-13 11_18_34-Book1 - Excel.png

 

The two tables are not related. What will happen is, the Selection table will be used for a chiclet/slicer. When the user selects a value (eg: Region), it will show a matrix table containing the calculated column and a measure showing the number of work orders by region. If they select Country, it will show the work orders by country instead; and if they select City, show work orders by city.

 

So basically, the calculated column is dynamic based on which item the user selects in the slicer (Selection[Option]), ie: it's just substituting which column to show depending on the user's selection.

 

ybzvtbB

Hi @olimilo ,

Have you solved your problem?

If you have solved the problem, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please feel free to ask.

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @olimilo ,

By my tests and research, we cannot achieve your desired output directly with measures.

If you do not want to unpivot your original Data Table, you could create a calculated table as a  workaroud.

Table =
UNION (
    SELECTCOLUMNS (
        'Data Table',
        "orderid", [Work OrderID],
        "type", "country",
        "value", [Country]
    ),
    SELECTCOLUMNS (
        'Data Table',
        "orderid", [Work OrderID],
        "type", "Region",
        "value", [Region]
    ),
    SELECTCOLUMNS (
        'Data Table',
        "orderid", [Work OrderID],
        "type", "city",
        "value", [City]
    )
)

Here is the output.

Capture.PNG

More details, you could refer to my attachment.

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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.