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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Axiomite
Resolver II
Resolver II

IF with SELECTEDVALUE nothing selected give total

Hi there, 

 

Need help with the following. I have a card and a slicer. Currently the filter is applied to the calculation based on selected value in a slicer.
Currently looking like this:

CR Current = CALCULATE(SUM(table1[column]),
                                         FILTER (table1, table1[slicercolumn]= SELECTEDVALUE(table1[slicercolumn])))+0

However, currentl if nothing is selected it shows 0.
How can I change it to show the the result without the filter when nothing is selected? 
 
So IFomething is selected in the slicer then 
CALCULATE(SUM(table1[column]),
                                         FILTER (table1, table1[slicercolumn]= SELECTEDVALUE(table1[slicercolumn])))+0
      ELSE
          CALCULATE(SUM(table1[column])

Hope it makes sense.
 
Many thanks
         

 
1 ACCEPTED SOLUTION
lukiz84
Memorable Member
Memorable Member

Hi,

 

try:

RETURN

IF(HASONEVALUE(table1[slicercolumn]), <yourCodeFromAbove>, SUM(table1[column]))

 

hth and br

View solution in original post

6 REPLIES 6
lukiz84
Memorable Member
Memorable Member

Hi,

 

try:

RETURN

IF(HASONEVALUE(table1[slicercolumn]), <yourCodeFromAbove>, SUM(table1[column]))

 

hth and br

Thanks, getting a blank return.

Try

RETURN IF(NOT(HASONEVALUE(table1[slicercolumn])), SUM(table1[column]))

 

to see if it's your code that returns blank... (debugging) 

@lukiz84 
many thanks, the debugging as per above suggested works fine, it returns a value. However, re trying the first example I still get no value returned selecting or not selecting a value in the slicer.

Can you show the slicer Table (where you apply HASONEVALUE) and the data table? Just some sample data...?

@lukiz84 

Many thanks for your help. I'm terribly sorry for wasting your time. Whilst preparing sample data thus isolating the table from quite a "HUGE" report I been such a data rookie. In the end my issues was on of the fields having a data type as text rather than decimal number. However, strangely enough I got no error message, rather just no return.
Thanks for you time in helping me get to the bottom of the problem. I will go an accept your solution. Thanks again!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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