Forum Discussion

ajitsahoo8338's avatar
ajitsahoo8338
Helper III
1 year ago

Need help with this issue

In My dataset there is one column i.e. 

Resource
Control
Electrical
TECH COMM

Mechanical
Fluid
Test

My requirement is to create a slicer. In that slicer there should two option to select "Yes" and "No" If the selection is "Yes" it should show all Resources Data and if the selection is "No" then it should exclude "TECH COMM" from the visual.

For That I have created this table in power bi-
Include TECH COMM Filter Table =

DATATABLE("Selection", STRING, {{"Yes"}, {"No"}}).
And Then I using this DAX in the filter

IF(

    SELECTEDVALUE('Include TECH COMM Filter Table'[Selection], "Yes") = "No",

    IF(MAX(Engineering_Projects_Dataset_V2[Resource]) = "TECH COMM", 0, 1),

    1

)

It is working when the Resource column in present in the view but not filtering properly when resource column is there in the visual

 

4 Replies

  • ajitsahoo8338 , Try like

     

    Dynamic Resource Filter Measure =
    VAR SlicerSelection = SELECTEDVALUE('Include TECH COMM Filter Table'[Selection], "Yes")
    RETURN
    SWITCH(
    SlicerSelection,
    "Yes", countrows(Table),
    "No", calculate(countrows(filter(Table, Engineering_Projects_Dataset_V2[Resource]) <> "TECH COMM")),
    countrows(Table)
    )

    • ajitsahoo8338's avatar
      ajitsahoo8338
      Helper III

      Hello amitchandak  Thank you for your response. In my visual, I have a project name with multiple measures. I need to filter the project name using that slicer.

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ajitsahoo8338 ,

    It is working when the Resource column in present in the view but not filtering properly when resource column is there in the visual

    Could you please explain the specific problem you are encountering in the form of screenshots?

    I created the data myself and tested it with the DAX you provided, but there was no problem on my side:


    Or could you provide the complete structure of your data?

    Best Regards,
    Dino Tao

    • ajitsahoo8338's avatar
      ajitsahoo8338
      Helper III

      Hello Anonymous  , I am attaching a structure of my data. Please check it. The DAX works when the Resource is present in the visual, but it does not work when I remove the resource from the visual.

      Project NumberResourceRecorded_Hours
      E0100CONTROL4
      E0100FLUID0.5
      E0100MECHANICAL10
      E0100TECH COMM6710.4
      E0117ELECTRICAL496.75
      E0117FLUID699.4
      E0117MECHANICAL1702
      E0117PROJECT512
      E0117TECH COMM270