Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

using less or equal in filter

Hi,   In a source table I have a field that contains a number between 1 and 50. In a page I want to show its records using a table vizualisation. I want to use a slicer with the values 5, 10, 15,...
  • Anonymous's avatar
    Anonymous
    7 years ago

    So to replicate your problem I have setup a table in power query that contains two columns, one with an Id column from 0 to 24 and another column with a random integer between 1 and 50 called values. Then I have created another table that just contains numbers between 5 and 50 in increments of 5. There are no relationships between these two tables.

     

    Then to get the result you require I have the following measure

     

     

    Values Filtered =
        IF (
            HASONEVALUE ( 'Filter Table'[Filter] ) && HASONEVALUE ( 'Table'[Id] ),
            CALCULATE (
                VALUES ( 'Table'[Value] ),
                FILTER ( ( 'Table' ), 'Table'[Value] <= VALUES ( 'Filter Table'[Filter] ) )
            ),
            BLANK ()
        )

    What it does is check if in the current context if there is only one value of Id, aka only one row of the Table is in the current context, and that there is only one value selected from the filter table. If either of these are false it will return blank, if you want some kind of aggregation it can be added.

     

     

    If the conditions are met then it will display the values that are less than or equal to the selected value of the fitler table.

     

    I hope this helps

     

  • Anonymous's avatar
    Anonymous
    7 years ago

    Anonymous,

    Yes if you use Anonymous's DAX. You can add an index column in Query Editor to represent ID.  




    Or you can change the DAX to the following ,for more details, please check attached PBIX file. It doesn't require Id column using this DAX.

    Measure = 
        IF (
            HASONEVALUE ( Parameter[Parameter] ) && HASONEVALUE ( 'Table1'[Value] ),
            CALCULATE (
                VALUES ( Table1[Value] ),
                FILTER ( ( 'Table1' ), Table1[Value] <= VALUES ( Parameter[Parameter] ) )
            ),
            BLANK ()
        )




    Regards,
    Lydia