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
sinfa
Frequent Visitor

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 def@gmail.com
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 abc@gmail.comPerson B456def@gmail.com
2Shop BUKLondonWestminster123abc@gmail.comPerson B def@gmail.com
3Shop CUKLondonWestminsterPerson A123abc@gmail.comPerson 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 EmailTextabc@gmail.com
1Contact 2 NameTextPerson B
1Contact 2 PhoneWhole Number456
1Contact 2 EmailTextdef@gmail.com
2LocationTextShop B
2CountryTextUK
2CityTextLondon
2BoroughTextWestminster
2Contact 1 NameText 
2Contact 1 PhoneWhole Number123
2Contact 1 EmailTextabc@gmail.com
2Contact 2 NameTextPerson B
2Contact 2 PhoneWhole Number
2Contact 2 EmailTextdef@gmail.com
3LocationTextShop C
3CountryTextUK
3CityTextLondon
3BoroughTextWestminster
3Contact 1 NameTextPerson A
3Contact 1 PhoneWhole Number123
3Contact 1 EmailTextabc@gmail.com
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 4
v-yangliu-msft
Community Support
Community Support

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:

vyangliumsft_0-1698048965488.png

vyangliumsft_1-1698048965494.png

 

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

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 abc@gmail.comPerson B456def@gmail.com
2Shop BUKLondonWestminster123abc@gmail.comPerson B def@gmail.com
3Shop CUKLondonWestminsterPerson A123abc@gmail.comPerson 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!

 

ALLUREAN
Solution Sage
Solution Sage

Hi, 

You can use field parameters to dynamically pick up the columns.

https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

 




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




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!

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.