Forum Discussion

sinfa's avatar
sinfa
Frequent Visitor
2 years ago

Dynamic Number of Columns With N Columns - Table Visual

Hello,

 

I am trying to create a drillthrough where the columns on the table visual are dynamically selected, and would really appreciate your help!

 

Basically, I have a summary table that shows a list of business rules and a count of locations that triggered it today only. When I click on a location count, I want to create a drillthrough page that'll show the list of locations and a bunch of location data that's related to the business rule. There are over 100 business rules and each location got several 100 columns too. The issue I'm facing is I only want to display columns that are relevant for each business rule, and the number of columns will vary depending on the business rule. There will be times where the relevant columns will overlap for different business rules. Here's what the summary table looks like:

 

BusinessRuleIDLocationCount
11
22
32

 

Is there a way where I can a table visual that'll dynamically pick the columns I need based on the business rule that I'm drilling through?

 

Here's a few examples of what I'm looking for:

 

If business rule #1 is about geographic consistency, on the drillthrough, I'll like the table visual to show LocationID, Location, Country, and City.

 

LocationIDLocationNameCountryCity
1Shop AUKMunich

 

If business rule #3 is about whether contact 2 details are all filled in, on the drillthrough, I'll like the table visual to show LocationID, Location, Contact 2 Name, Contact 2 Phone, Contact 2 Email.

 

LocationIDLocationNameContact 2 NameContact 2 PhoneContact 2 Email
2Shop BPerson B [email protected]
3Shop CPerson B456 

 

Here's the underlying data that I have at the moment:

 

RESULTS - A table containing all the locations, what business rules did it trigger, and what date (today's date is 20th Oct 2023 for me)

 

ResultsIDLocationIDBusinessRuleIDDate
11118/10/23
21119/10/23
31120/10/23
41220/10/23
52220/10/23
62320/10/23
73320/10/23

 

BUSINESS RULES - A table with list of business rules, as well as thier name and description

 

BusinessRuleIDNameDescription
1Inconsistent Geography (High Level)Country and City don't match
2Incomplete Contact 1 DetailsThere are blanks on contact 1's name, email or phone - they're all compulsory
3Incomplete Contact 2 DetailsThere are blanks on contact 2's name, email or phone - they're all compulsory

 

For LOCATION data, here's the original table:

 

LocationIDLocationCountryCityBoroughContact 1 NameContact 1 PhoneContact 1 EmailContact 2 NameContact 2 PhoneContact 2 Email
1Shop AUKMunichWestminsterPerson A [email protected]Person B456[email protected]
2Shop BUKLondonWestminster123[email protected]Person B [email protected]
3Shop CUKLondonWestminsterPerson A123[email protected]Person B456 

 

Lastly, I believe I can transpose/pivot the data, and got stuck on what to do next:

 

LocationIDColumnNameColumnTypeColumnValue
1LocationTextShop A
1CountryTextUK
1CityTextMunich
1BoroughTextWestminster
1Contact 1 NameTextPerson A
1Contact 1 PhoneWhole Number
1Contact 1 EmailText[email protected]
1Contact 2 NameTextPerson B
1Contact 2 PhoneWhole Number456
1Contact 2 EmailText[email protected]
2LocationTextShop B
2CountryTextUK
2CityTextLondon
2BoroughTextWestminster
2Contact 1 NameText 
2Contact 1 PhoneWhole Number123
2Contact 1 EmailText[email protected]
2Contact 2 NameTextPerson B
2Contact 2 PhoneWhole Number
2Contact 2 EmailText[email protected]
3LocationTextShop C
3CountryTextUK
3CityTextLondon
3BoroughTextWestminster
3Contact 1 NameTextPerson A
3Contact 1 PhoneWhole Number123
3Contact 1 EmailText[email protected]
3Contact 2 NameTextPerson B
3Contact 2 PhoneWhole Number456
3Contact 2 EmailText 

 

Is what I'm trying to do even possible?

 

Thanks a bunch!

 

4 Replies

    • sinfa's avatar
      sinfa
      Frequent Visitor

      Thanks for your reply 🙂

      I thought about using field parameters as well, but not exactly sure how to implement it. Do you mind elaborating a bit more?

       

      Thanks!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  sinfa ,

     

    Here are the steps you can follow:

    1. Create measure.

    Measure =
    var _select=SELECTEDVALUE('Table A'[BusinessRuleID])
    var _column=SELECTCOLUMNS(FILTER(ALL('Table A'),'Table A'[BusinessRuleID] =_select),"LocationID",[LocationID])
    return
    SWITCH(
        TRUE(),
        _select = 1 &&MAX('Table'[ColumnName]) in {"Country","Location","City"},MAX('Table'[ColumnValue]),
        _select =3 && MAX('Table'[ColumnName]) in {"Location","Contact 2 Name","Contact 2 Phone","Contact 2 Email"},MAX('Table'[ColumnValue]),BLANK())

    2. Result:

     

    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

    • sinfa's avatar
      sinfa
      Frequent Visitor

      Hi Liu Yan,

       

      Thanks for your reply.

       

      I'm getting an issue where the visual has exceeded the available resources, which might be due to the volume of the data.

       

      Would it be possible to do something similar if Table A was actually pivoted like the original LOCATION table, like this:

       

      LocationIDLocationCountryCityBoroughContact 1 NameContact 1 PhoneContact 1 EmailContact 2 NameContact 2 PhoneContact 2 Email
      1Shop AUKMunichWestminsterPerson A [email protected]Person B456[email protected]
      2Shop BUKLondonWestminster123[email protected]Person B [email protected]
      3Shop CUKLondonWestminsterPerson A123[email protected]Person B456 

       

      Also, would it be possible to automate the selection without hardcoding it in the switch by adding a new table inbetween Table and Table A that'll look like this:

       

      BusinessRuleIDColumnNameColumnOrder
      1Country1
      1City2
      3Contact 2 Email1
      3Contact 2 Name2
      3Contact 2 Phone3

       

      Thanks for your help again, really appreciate it!