Forum Discussion

Gurpreet-12345's avatar
Gurpreet-12345
Regular Visitor
1 year ago
Solved

data filtering in matrix visual

Hello All Need one solution with my matrix table.I have one matrix visual which shows server names along with the time how many times the system has been logged in ,in the particular time frame. Exa...
  • shafiz_p's avatar
    1 year ago

    Hi Gurpreet-12345  As I can understand that you want the ability to filter matrix with current selection from slicer should be non zero and previous time frame should be zero.

    I have tried to implement such scenario using disconnected table, individual measure for each login period, field value and visual level filter measure. 

    I have a simple data table with only username and login date. Want to count total number of login for each user in a time period.

    I have a calendar table and related with date to each other one to many relationship. Check out:

     

    Then created countrows measure:

    Countrows = 
    IF(
        ISBLANK(COUNTROWS(LoginTable)),
        0,
        COUNTROWS(LoginTable)
    )

     

    I have 5 time period in calendar table: 7D, 15D, 30D, 60D, and >60D. Check out:

     

    Created 5 individual measure for each time period. Check:

    7D = CALCULATE([CountRows], 'Calendar'[TimeFrame] = "7D")
    15D = CALCULATE([CountRows], 'Calendar'[TimeFrame] = "15D")
    30D = CALCULATE([CountRows], 'Calendar'[TimeFrame] = "30D")
    60D = CALCULATE([CountRows], 'Calendar'[TimeFrame] = "60D")
    >60D = CALCULATE([CountRows], 'Calendar'[TimeFrame] = ">60D")

     

    Create a field value without slicer. Check this:

     

    Now created matrix with user (for my case) in rows and newly created TimeFrame fieldvalue in Values section. See my matrix visual:

     

    Now create a disconnected TimeFrame table because we don't want to filter underlying data table. To create a disconnected table with distinct TimeFrame and Index (for sorting in slicer), try use summarize or you can use power query:

     

    Now create a slicer with this TimeFrame column. Now create measure for visual level filter. Try below code:

    SelectedMeasure = 
    SWITCH(
        TRUE(),
        ISBLANK(SELECTEDVALUE(TimeFrame[TimeFrame])), [7D] + [15D] + [30D] + [60D] + [>60D],
        SELECTEDVALUE(TimeFrame[TimeFrame]) = "7D", IF([7D] <> 0, [7D], BLANK()),
        SELECTEDVALUE(TimeFrame[TimeFrame]) = "15D", IF([15D] <> 0 && [7D] = 0, [15D], BLANK()),
        SELECTEDVALUE(TimeFrame[TimeFrame]) = "30D", IF([30D] <> 0 && [15D] = 0 && [7D] = 0, [30D], BLANK()),
        SELECTEDVALUE(TimeFrame[TimeFrame]) = "60D", IF([60D] <> 0 && [30D] = 0 && [15D] = 0 && [7D] = 0, [60D], BLANK()),
        SELECTEDVALUE(TimeFrame[TimeFrame]) = ">60D", IF([>60D] <> 0 && [60D] = 0 && [30D] = 0 && [15D] = 0 && [7D] = 0, [>60D], BLANK())
    )

     

    Place this measure in filter this visual section in filter pane and set to is not blank. Check out:

     

    You are done. Now you will be able to filter current measure with non zero and all the previous time frame is zero. Check out output:

    Output 1 (When 7D selected):

     

    Output 2 (When 15D selected):

     

    Output 3 (When 30D Selected):

     

    See, for 30D we have only one rows where current selection is non zero and previous is zeros.

     


    Hope this helps!!

    If this solved your problem, please accept it as a solution and a kudos!!

     

    Best Regards,
    Shahariar Hafiz