Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Abbi
Helper I
Helper I

DAX filter

Hi All,

 

Your help is required.

I have a table with ID details. 

IDDependecy AgePriority
345Client121
385Supplier32
8425Paper Work51
998Client152
5428Client213
4832Client141
345Application441
441Client532
8425Client322
3382Client61

 

My output has to be 

ID
998
4832
441
8425

 

Conditions to be satisfied:

  1. Priority = 1 or 2
  2. Age > 10
  3. After satisfying the first 2 conditions, if the ID has only 1 dependency (i.e. Client) then we have to get the ID to the table
  4. After satisfying the first 2 filters, if the ID has more than 1 dependency then we shouldn’t get the ID to the table.

 

I was able to apply first 2 conditions, but 3rd condition is not striking my head.

 

Please help.

 

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

Please check the below. It is for creating a new table.

 

Picture1.png

 

New table =
VAR newtable =
FILTER ( Data, Data[Priority] IN { 1, 2 } && Data[Age] > 10 )
VAR countdependency =
GROUPBY ( newtable, Data[ID], "@count_dependency", SUMX ( CURRENTGROUP (), 1 ) )
RETURN
SUMMARIZE ( FILTER ( countdependency, [@count_dependency] = 1 ), Data[ID] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim @Samarth_18 , Sorry if I had lead you in wrong way.

Here the condition is not count of dependency, We require only ID'd with Client dependency. If the ID has Client and Application dependecy and both of them satify the priority and age conditions then we shouldn't pull that ID.

 

We have to pull only the ID's ( can be repeated any number of times), but it has only Client dependecy .

 

 

Hi @Abbi 

 

Use below measure as a filter field on the table visual to get the result. SELECTEDVALUE() returns a single dependency value. If an ID has more than one dependencies, it will return blank. 

Flag = 
VAR _dependency =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Dependecy ] ),
        FILTER ( 'Table', 'Table'[Priority] IN { 1, 2 } && 'Table'[Age] > 10 )
    )
RETURN
    IF ( _dependency = "Client", 1, 0 )

22010402.jpg

 

Or if you want to have the filtered result in a new table, you can use 

Table 2 = 
SELECTCOLUMNS (
    FILTER (
        SUMMARIZE (
            FILTER ( 'Table', 'Table'[Priority] IN { 1, 2 } && 'Table'[Age] > 10 ),
            'Table'[ID],
            "dependency", SELECTEDVALUE ( 'Table'[Dependecy ] )
        ),
        [dependency] = "Client"
    ),
    "id", [ID]
)

22010403.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Samarth_18
Community Champion
Community Champion

Hi @Abbi ,

 

Create a measure like this and use it as filter:-

_filter = count('Table (2)'[Dependecy ])

 Output:-

Samarth_18_0-1639634503341.png

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors