Forum Discussion

KBD's avatar
KBD
Icon for Helper III rankHelper III
4 months ago
Solved

using a slicer to control which attributes a table is filter by

Hello All:   I have transaction data, lets say it is petty cash purchases.   I am using slicers to filter the table on the fly. The usual slicers, department,  party making purchase, day of week,...
  • MFelix's avatar
    MFelix
    4 months ago

    Hi KBD ,

     

    For this you need to have a different syntax because when you do ColumnValues == "" or ISBLANK(ColumnnValues) this is expecting a single value to do the comparision since the no selection on a slicer correspond to selecting all then you have an error of multiple values supplied.

     

    Other thing is that having everything selected on the slicer or no selection gives the same result so you have to change your measure to pick up the filtering.

     

    For this try the following code:

    Filter Blanks II = VAR __SelectedValue =
    		SELECTCOLUMNS(
    			SUMMARIZE(
    				fields,
    				fields[fields],
    				fields[fields Fields]
    			),
    			fields[fields]
    		)
    
        var ColumnValues = VALUES(fields[fieldName])
    	
        VAR temptable =
    		SELECTCOLUMNS(
    			Sheet1,
    			Sheet1[Employee Name],
    			Sheet1[Employee Id],
    			Sheet1[Expense Description],
    			Sheet1[MCC],
    			Sheet1[Merchant Name],
    			Sheet1[Transaction Date],
    			"Blank count", 
    			IF ( 
    			     ISFILTERED(fields[fields Fields]) ,
    				 			
    			IF(
    				"Employee Name" IN ColumnValues,
    				1 * ISBLANK(Sheet1[Employee Name])
    			) +
    			IF(
    				"Employee ID" IN ColumnValues,
    				1 * ISBLANK(Sheet1[Employee ID])
    			) +
    			IF(
    				"Expense Description" IN ColumnValues,
    				1 * ISBLANK(Sheet1[Expense Description])
    			) +
    			IF(
    				"Transaction Date" IN ColumnValues,
    				1 * ISBLANK(Sheet1[Transaction Date])
    			) +
    			IF(
    				"MCC" IN ColumnValues,
    				1 * ISBLANK(Sheet1[MCC])
    			) +
    			IF(
    				"Merchant Name" IN ColumnValues,
    				1 * ISBLANK(Sheet1[Merchant Name])
    			)
    			    ,1
    		    )
            )
    		RETURN
    			MAXX(
    				temptable,
    				[Blank count] 
    			)
                

     

    In this case the ISFILTERED allows to show if you have any selection on the filter, be aware that in this case having no selection returns all rows having all values selected in the slicer returns the ones with blanks:

     

     

     

     

    Concerning the first row on your example I was not able to replicate it but seems to be working fine on my side.