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
Applicable88
Impactful Individual
Impactful Individual

Blank() in Card Visual with another condition

Hello,

I'm using following measure to sum the InOut under the condition to filter the card visual only when I selected a stockmaterial and also replaced the typical blank when nothing is selected with "Please select stockmaterial":

 
IF ( ISFILTERED([Stockmaterial]), SUM([InOut]), "Please select stockmaterial")
 
Stockmaterial Index                      InOut
a i 1000
aa o -1000
bb i 800
bb o -750
c i 32
d i 4234
d i 757
e i 234
e i 234
a o -683
a o -962

I have three card visuals:
1.Shows only the "inbounds" with index i 
2.Shows only the "outbounds" with index o
3. Shows overall balance of selected stockmaterial. 
 
What I want to archieve is that when I select a stockmaterial with no outbound yet that the outbound cardvisual always show blank() instead of "0". 
IF ( ISFILTERED([Stockmaterial]), SUM([InOut]), if(isfiltered([Stockmaterial]) && isblank(SUM[InOut]), 0, "Please select stockmaterial"))
 
I also tried with  ....&& sum([InOut])=0...
 
The syntax is ok but the card visuals are returning errors. 
Thank you very much in advance. 
Best. 

 

 

 

 

 
2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @Applicable88 

 

Download example PBIX file with the following code and visuals.

 

I'm not sure if you are asking to show 0 or BLANK() in trhe card visuals.  Either way, it's easy to change.

 

Using these 3 measures

 

 

Sum InOut = IF ( ISFILTERED('DataTable'[Stockmaterial]), CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[Stockmaterial] = SELECTEDVALUE('DataTable'[Stockmaterial]))), "Please select stockmaterial")

 

 

 

 

Sum Ins = CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[index] = "i" && 'DataTable'[Stockmaterial]= SELECTEDVALUE('DataTable'[Stockmaterial]))) + 0

 

 

 

Sum Outs = CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[index] = "o" && 'DataTable'[Stockmaterial]= SELECTEDVALUE('DataTable'[Stockmaterial]))) + 0

 

 

Will give you the desired outputs in your cards

stock1.png

stock3.pngstock2.png

If you want the Sum In and Sum Out cards to show BLANK() rather than 0, remove the + 0 from the end fo each measure, e.g.

Sum Outs = CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[index] = "o" && 'DataTable'[Stockmaterial]= SELECTEDVALUE('DataTable'[Stockmaterial])))

sumout.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

v-xiaotang
Community Support
Community Support

Hi @Applicable88 

"What I want to archieve is that when I select a stockmaterial with no outbound yet that the outbound cardvisual always show blank() instead of "0". "

You can try this measure

Measure = 
    var _value=CALCULATE(SUM('Table'[InOut]),FILTER(ALLEXCEPT('Table','Table'[Stockmaterial]),'Table'[InOut]<0))
return 
    IF(ISFILTERED('Table'[Stockmaterial]),IF(ISBLANK(_value),BLANK(),_value),"Please select stockmaterial")

vxiaotang_0-1636971054763.pngvxiaotang_1-1636971068024.pngvxiaotang_2-1636971076263.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @Applicable88 

"What I want to archieve is that when I select a stockmaterial with no outbound yet that the outbound cardvisual always show blank() instead of "0". "

You can try this measure

Measure = 
    var _value=CALCULATE(SUM('Table'[InOut]),FILTER(ALLEXCEPT('Table','Table'[Stockmaterial]),'Table'[InOut]<0))
return 
    IF(ISFILTERED('Table'[Stockmaterial]),IF(ISBLANK(_value),BLANK(),_value),"Please select stockmaterial")

vxiaotang_0-1636971054763.pngvxiaotang_1-1636971068024.pngvxiaotang_2-1636971076263.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-xiaotang !

PhilipTreacy
Super User
Super User

Hi @Applicable88 

 

Download example PBIX file with the following code and visuals.

 

I'm not sure if you are asking to show 0 or BLANK() in trhe card visuals.  Either way, it's easy to change.

 

Using these 3 measures

 

 

Sum InOut = IF ( ISFILTERED('DataTable'[Stockmaterial]), CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[Stockmaterial] = SELECTEDVALUE('DataTable'[Stockmaterial]))), "Please select stockmaterial")

 

 

 

 

Sum Ins = CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[index] = "i" && 'DataTable'[Stockmaterial]= SELECTEDVALUE('DataTable'[Stockmaterial]))) + 0

 

 

 

Sum Outs = CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[index] = "o" && 'DataTable'[Stockmaterial]= SELECTEDVALUE('DataTable'[Stockmaterial]))) + 0

 

 

Will give you the desired outputs in your cards

stock1.png

stock3.pngstock2.png

If you want the Sum In and Sum Out cards to show BLANK() rather than 0, remove the + 0 from the end fo each measure, e.g.

Sum Outs = CALCULATE(SUM('DataTable'[InOut]), FILTER(ALL('DataTable'), 'DataTable'[index] = "o" && 'DataTable'[Stockmaterial]= SELECTEDVALUE('DataTable'[Stockmaterial])))

sumout.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thank you @PhilipTreacy !

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.