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
StuartSmith
Power Participant
Power Participant

Streamline Code

All, I have the below code running on multiple cards (10's) and ideally want to find a way to streamline it as i suspect its slowing down the report.  

 

Address_Measure = IF(ISFILTERED('Location Overview'[Country]) && HASONEVALUE('Location Overview'[Country]) || ISFILTERED('Location Overview'[City]) && HASONEVALUE('Location Overview'[City]) || ISFILTERED('Location Overview'[Building Code]) && HASONEVALUE('Location Overview'[Building Code]), IF(COUNT('Location Overview'[Address]) =1, LASTNONBLANK('Location Overview'[Address],""), ""), "")

 

The code checks 3 slicers (Country, City and Building Code) that nothing is selected and if so, displays a blank/empty value on the cards.  This code has to run on each card, which isnt ideal and is there a way to streamline/reduce the code so that, i guess it has something like...

 

Address_Measure = IF(ISFILTERED(All 'Slices') && HASONEVALUE(''All Slices), IF(COUNT('Location Overview'[Address]) =1, LASTNONBLANK('Location Overview'[Address],""), "")

 

or with the help of you lot, an even better way, such as code that loads when the report loads that will check no slicers are selected and apply code to all cards...

 

Address_Measure = IF(ISFILTERED(All 'Slices') && HASONEVALUE(''All Slices), IF(COUNT('Location Overview'[Address]) =1, LASTNONBLANK('Location Overview'[Address],""), to all card)

 

Thanks in advance, 

 

 

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @StuartSmith 

Could you show the "Fields" pane for the Map visual to let me know which columns you add in the map?

Could you show an example of you data?

for example, these are in one table, are your columns added in the map from one table and does the table atructure like this?

country city building code address
a aa 1 qeqwe
a aa 2 erer
a aa 3 retr
a ab 4 tr
a ab 5 treyrte
a ab 6 tytr
b bb 7 ytry
b bb 8 uyruyu
b bb 9 uryiyiuyiuy

Additionally, according to this article "Power BI performance best practices",

To improve the performance of the report, please reduce the numbers of visuals on one page of the report.

 

 

Best Regards

Maggie

 

v-juanli-msft
Community Support
Community Support

Hi @StuartSmith 

Could you show some data example for better analysis?

There is a guide blog How to Get Your Question Answered Quickly in this forum.

It will be much appreciated if you follow the suggestions in this blog to illustrate problem here.

 

Best Regards

Maggie

 

 

 

Most of the data is business related, so cant post data sets, but the Dashboard/Report looks like this below, and by default, all visuals are blank until either a map bubble or slicer is selected.  Therefore, everytime a bubble or silcer is selected, it has to run...

 

Address_Measure = IF(ISFILTERED('Location Overview'[Country]) && HASONEVALUE('Location Overview'[Country]) || ISFILTERED('Location Overview'[City]) && HASONEVALUE('Location Overview'[City]) || ISFILTERED('Location Overview'[Building Code]) && HASONEVALUE('Location Overview'[Building Code]), IF(COUNT('Location Overview'[Address]) =1, LASTNONBLANK('Location Overview'[Address],""), ""), "")

 

for each visual (approx 33) and just feel this could be causing slow down of loading results, although it might be minimal and therefore wondering if there is a better way to get the same result.  Dashboard Example.png

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.