cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
StuartSmith Frequent Visitor
Frequent Visitor

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
Community Support Team
Community Support Team

Re: Streamline Code

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

 

 

 

StuartSmith Frequent Visitor
Frequent Visitor

Re: Streamline Code

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

Community Support Team
Community Support Team

Re: Streamline Code

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