Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
StuartSmith
Power Participant
Power Participant

Stop cards displaying first row of data table.

All, I have just been introduced to Power BI by my boss and he has given me a small project to do, to aid my learning in Power BI.  I have a map visual showing all our offices based on address.  I then have several cards underneath to display the office address and manager, with the cards being called "Address" and "Manager" when an office bubble is selected from the map and this works great.

 

BUT, if I select anywere in the map, not on an office bubble, the cards display the office details of the first row in the data table, which looks out of place.  How can i get the cards to stop displaying the first row of the data table if a map bubble isnt selected.

 

 

Thanks in advance,

 

* edited description to make more sense.

 

1 ACCEPTED SOLUTION

Finally got it working, all by myself Smiley Happy  the code was right, just have to create a measure of each card and update the code slightly,  Anyway, all working and just need to test to make sure there are no odditities. 

 

{pats self on back}.

View solution in original post

11 REPLIES 11
TachoArancibia
New Member

Thank you. It was just what I need it. 😁

Glad it helped.  Its nice to be able to help someone , instead of people always helping me.   I actually improved on the code as found it cumbersom so slow to run on multiple cards, so i figured I could reduce the measure from...

 

5G_in_Country_Measure = IF(ISFILTERED('Carrier Matrix'[Region]) && HASONEVALUE('Carrier Matrix'[Region]) || ISFILTERED('Carrier Matrix'[Country]) && HASONEVALUE('Carrier Matrix'[Country]) || ISFILTERED('Carrier Matrix'[Carrier]) && HASONEVALUE('Carrier Matrix'[Carrier]) || ISFILTERED('Carrier Matrix'[OData__2_Contractstatus/planning]) && HASONEVALUE('Carrier Matrix'[OData__2_Contractstatus/planning]), IF(COUNT('Carrier Matrix'[Key]) =1, LASTNONBLANK('Carrier Matrix'[OData_5GAvailable]," "), " "), " ")

 

down to 

 

Country_Measure Test= IF(COUNT('Carrier Matrix'[Key]) =1, LASTNONBLANK('Carrier Matrix'[Country]," "), " ")

 

So instead of checking each slicer to see if it had been "filtered" or "has one value", i scrapped that part and just counted the table and if the table only had one row, it displayed that row, otherwise, remained blank.  Hopefully this will help.

StuartSmith
Power Participant
Power Participant

Thanks guys, I managed to splice together various solutions to get it so that if I select a bubble on the map it displays the approriate date in the card, and then if I select anywhere in the map (not on data bubble), the card is blank, so getting there.

 

The code to do that is: 

HQ_Measure = IF(ISFILTERED('Location Overview'[Address]) && HASONEVALUE('Location Overview'[Address]), LASTNONBLANK('Location Overview'[HQ], ""), "")
 
the trouble is I also have 3 slices on the page to also filter the results.  With one of the filters beign called "Country_Slicer".  When i use a slicer, it doesnt update the card and suspect I need an AND/OR part to the code, but cant get the correct format.  I have done lots of seaching, but cant find anything that helps.  How should my script look so it not only checks the map, but also the slicers.

Also, how would I get the "LASTNONBLANK" section to clear multiple columns and not just the "HQ" one.  I have tried various formats, but it either doesnt work or for some reason displays "False" on the HQ Card.

 

HQ_Measure = IF(ISFILTERED('Location Overview'[Address]) && HASONEVALUE('Location Overview'[Address]), LASTNONBLANK('Location Overview'[HQ], ""), "")

Nothing like a fresh weekend head to get the grey matter working, as slowly making progress, as I have now got the DAX code only displaying a value in a card if either a map data bubble is selected or a value is selected in a dropdown slicer.  Just one final issue in trying to get the code to apply to multiple cards.

 

This is the current code...

HQ_Measure = IF(ISFILTERED('Location Overview'[Address]) && HASONEVALUE('Location Overview'[Address]) || ISFILTERED('Location Overview'[Building Code]) && HASONEVALUE('Location Overview'[Building Code]), LASTNONBLANK('Location Overview'[HQ], ""), "")

 

How can I get multiple "LASTNONBLANK" values?  i beleive this is the "IF True" output value for the IF Statement.  Can you have multiple IF TRUE output values? if so, how.  I have tried various combination of "AND" and "&&" in different places, but no joy.

 

Thanks in advance,

 

 

 

Finally got it working, all by myself Smiley Happy  the code was right, just have to create a measure of each card and update the code slightly,  Anyway, all working and just need to test to make sure there are no odditities. 

 

{pats self on back}.

StuartSmith
Power Participant
Power Participant

Still struggling with this, and its the only thing outstanding to do, before I can show my boss.  Any further guidence would be greatly appreciated. 

@StuartSmith,

 

See the post below as an example.

https://community.powerbi.com/t5/Desktop/Dynamic-text-based-on-slicer/m-p/214504#M94883

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

Hi @StuartSmith

 

to provide a solution, we would need to see your file

 

 

 


 


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


Proud to be a Datanaut!  

LivioLanzo
Solution Sage
Solution Sage

Hi @StuartSmith

 

It can be done, You will have to play with the measure used in your card and add a condition with HASONEVALUE 

 


 


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


Proud to be a Datanaut!  

StuartSmith
Power Participant
Power Participant

I should add, that I have searched the web and found various solutions, but i was either unable to translate to my setup or were not right for my requirements. 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.