Forum Discussion

Jp_ON's avatar
Jp_ON
Frequent Visitor
1 year ago
Solved

PathContains from SelectedValue issue with GUID

I have a Table of equipment records that are connected through the Account to Regions. When I attempt to use the PATHCONTAINS() with SELECTEDVALUE() It always returns False() where if I hard code ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Jp_ON ,

    Thanks for your detailed reply. I updated my sample pbix file, please check if that is what you want. Please update the formula of measure [HeirarchyRegionInPath] as below:

    HeirarchyRegionInPath_New = 
    VAR _Selectedname =
        SELECTEDVALUE ( 'Region list'[Name] )
    VAR _account =
        SELECTEDVALUE ( 'Units'[Account] )
    VAR _terr =
        CALCULATETABLE (
            VALUES ( 'esi_region'[esi_territory] ),
            FILTER (
                'esi_region',
                IFERROR ( SEARCH ( _Selectedname, 'esi_region'[Name], 1, 0 ), 0 ) > 0
            )
        )
    VAR _accounts =
        CALCULATETABLE (
            VALUES ( 'account'[Name] ),
            FILTER ( 'account', 'account'[esi_territory] IN _terr )
        )
    RETURN
        IF ( _account IN _accounts, 1 )

    Best Regards

  • Jp_ON's avatar
    1 year ago

    Took a few rounds but this was what we landed on. 

    Have a Table used for Selecting region(Region list) so that the relationships between tables doesn't restrict the avaialble Regions.


    Define 

    HierarchyPath = PATH(Regions[esi_regionid],Regions[Parent Region (esi_region)])


    Then against the Region table this Column is added and we filter the grids based on "RegionInPath is 1"

    RegionInPath =
    VAR SelectedRegion = SELECTEDVALUE('Region list'[Region])
    VAR FilteredTable =
        FILTER(regions, PATHCONTAINS(Regions[HierarchyPath], SelectedRegion))
    RETURN
        IF (
            ISBLANK(SelectedRegion),
            1, -- Show all records if no slicer is selected
            IF (
                ISEMPTY(FilteredTable),
                0, -- Record doesn't match filter
                1  -- Record matches filter
            )
        )