cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Count ID's among hierarchies Paths in DAX

 

HI DATANUTS!!!

 

For sure this is a simple one.

 

I have an UNPIVOTED hierarchies table "[DIM_SET]". Some characteristics of this table are:

 

  • Children levels with multiple Fathers
  • Children could also be Fathers on upper levels

 

From wat we already now, DAX doesn’t support this type of hierarchies natively. Therefore, I build this “UNPIVOTED” hierarchies table in Access. I also added the “PATH” column to be able to use some DAX path functions.

 

SET.PNG

 

 

I’m trying to build a calculated column (L2_PATHS_COUNTROWS) to count how many times each L2 id is present among all paths.

 

Here I have an example for L2 id “1465660” :

 

L2_PATHS_COUNTROWS = COUNTROWS(FILTER(DIM_SET;PATHCONTAINS(DIM_SET[PATH];"1465660")))

 

The result is 8 and it is correct. Now I need to perform this calculation for each L2 id row.

 

THANKS IN ADVANCE!Smiley Wink

 

DIM_SET.TXT (LINK)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Count ID's among hierarchies Paths in DAX

Hi @Anonymous ,

 

As the sharing link has expired.So I create a sample for your refernce. Please create a calculated column using the formula.

 

Column =
CALCULATE (
    COUNTROWS ( DIM_SET ),
    FILTER (
        ALLEXCEPT ( DIM_SET, DIM_SET[L2] ),
        PATHCONTAINS ( DIM_SET[Path], DIM_SET[L2] )
    )
)

Capture.PNG

 

Attched the pbix:)

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

Re: Count ID's among hierarchies Paths in DAX

Hi @Anonymous,

 

To create a calculated column as below. If it doesn't meet your requirement, kindly share your sample data to me,  if you don't have confidential data? Please upload your file to One Drive and share the link here.

 

Measure = CALCULATE(COUNT(DIM_SET[L2]),FILTER(DIM_SET,DIM_SET[L2]=1465660))

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Highlighted
Anonymous
Not applicable

Re: Count ID's among hierarchies Paths in DAX

Just updated the post with the file link. 

 

This formula is a MEASURE, I need a CALCULATED COLUMN that evaluates the column [PATH] for each row of [L2] counting in how many paths each [L2] Id is present.

 

Thank you.

Highlighted
Community Support
Community Support

Re: Count ID's among hierarchies Paths in DAX

Hi @Anonymous ,

 

As the sharing link has expired.So I create a sample for your refernce. Please create a calculated column using the formula.

 

Column =
CALCULATE (
    COUNTROWS ( DIM_SET ),
    FILTER (
        ALLEXCEPT ( DIM_SET, DIM_SET[L2] ),
        PATHCONTAINS ( DIM_SET[Path], DIM_SET[L2] )
    )
)

Capture.PNG

 

Attched the pbix:)

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Highlighted
Community Support
Community Support

Re: Count ID's among hierarchies Paths in DAX

Hi @Anonymous ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Highlighted
Anonymous
Not applicable

Re: Count ID's among hierarchies Paths in DAX

Thanks!!!

 

Short answer is yes, THE FORMULA IS CORRECT. Now, it is IMPOSSIBLE TO APPLY due to the performance.  On the example attached I see that you reduced the hierarchies to run the formula, but unfortunately for an 85k rows hierarchies table it is impossible to run it.  Instead I used a MEASURE for each level.

 

 

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors
Top Kudoed Authors