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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
itsmebvk
Continued Contributor
Continued Contributor

How to filter on Child levels (Dimensional) based on Parent level value?

 Hi Folks,

 

I need small help in dimensional function. I am trying to crate a Matrix with following requirement using a hierarchy I have.

 

Attched Sample Data and PBI FIle

 

My requirement is when my Level3 =A3 I want to filter my Level3, Leve4, Level5 columns for only Location number 1 and 2, all other levels values should display as is.

 

For Eg : As highlighted below I created a sample measure when Level3 =A3 I want to filter all Level3=A3 and its child levels to Location number 1 and 2

 

Level1Level2Level3Level4Level5Sales
ORGAA1A11Milk100
ORGAA2A21Rice120
ORGAA2A21Bread25
ORGAA3A31Orange80
ORGAA3A32Apple140
ORGAA3A31Beer30
ORGAA1A11Mango11
ORGAA1A11Grapes45
ORGAA1A11Avocado66
ORGAA2A22Medicine

41

 

 

 

itsmebvamsi_0-1600503887553.png

 

I tried to use Path function but it only allows 2 columns to generate path, but as I have multiple columns in  hierarchy I am unable to use it,

 

Can you please suggest any workarounds or inputs to crack this requirement? 

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
itsmebvk
Continued Contributor
Continued Contributor

 

Finally I found solution to my issue. I created two measures with following expressions

 

Test = IF(HASONEVALUE('Levels Table'[Level3]) && SELECTEDVALUE('Levels Table'[Level3])="A3",CALCULATE(SUM('Sales by Location'[Sales]),FILTER('Sales by Location','Sales by Location'[Location] IN {1,2})),IF(HASONEVALUE('Levels Table'[Level3]),SUM('Sales by Location'[Sales])))


Test 2 = SUMX(VALUES('Levels Table'),[Test])

 

And used second measure in Matrix...bingo it worked .

 

 

itsmebvamsi_0-1600871496455.png

 

 

View solution in original post

8 REPLIES 8
Fowmy
Super User
Super User

@itsmebvk 

Where is the location information as per your source table, you have level 1 to 5 and the sales. What you do mean by location here?
Please provide the expected result as well.

Hope you need a measure.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

itsmebvk
Continued Contributor
Continued Contributor

@Fowmy  Thanks for your reply.

 

I have a table called location from there I will take Location number and I will take levels from Hierarchy table. And I want to create a measure by filtering on that Location.

 

My current rows are in column B4-B23 rows, I have highlighted my expected result in column C4-C23 rows. If you observe C18-C23 rows it is in red color and filtered using Location number.

 

Thank you.

@itsmebvk 

What is the relationship between the hierarchy and the location table, provide sample data of the location as well.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

itsmebvk
Continued Contributor
Continued Contributor

@Fowmy @amitchandak the relation between Hierarchy and Sales by Location tables is 1:N.

Can you please look at the attched sample data file and desired output.

Thank you.

itsmebvk
Continued Contributor
Continued Contributor

Hi Folks,

 

Can someone please share your thoughts or workarounds to this requirement.

 

Thanks in advance.

 

Regards

BVK

itsmebvk
Continued Contributor
Continued Contributor

@Greg_Deckler 

Hi Folks,

 

Finally I found a workaround to get close to this requirement, but I see small issue in it. I used following expression to filter Level3 and below Levels because of that levels above Leve3 and the totals are not updating. 

 

 

 

Test = IF(SELECTEDVALUE('Levels Table'[Level3])="A3",CALCULATE(SUM('Sales by Location'[Sales]),FILTER('Sales by Location','Sales by Location'[Location] IN {1,2})),SUM('Sales by Location'[Sales]))

 

 

 

itsmebvamsi_0-1600714643876.png

 

Can you suggest me any corrections to get correct totals? Please check the attached sample file.

 

Thank you.

 

 

itsmebvk
Continued Contributor
Continued Contributor

 

Attaching Sample Data and PBI file, if possible please check the issue in PBI file.

itsmebvk
Continued Contributor
Continued Contributor

 

Finally I found solution to my issue. I created two measures with following expressions

 

Test = IF(HASONEVALUE('Levels Table'[Level3]) && SELECTEDVALUE('Levels Table'[Level3])="A3",CALCULATE(SUM('Sales by Location'[Sales]),FILTER('Sales by Location','Sales by Location'[Location] IN {1,2})),IF(HASONEVALUE('Levels Table'[Level3]),SUM('Sales by Location'[Sales])))


Test 2 = SUMX(VALUES('Levels Table'),[Test])

 

And used second measure in Matrix...bingo it worked .

 

 

itsmebvamsi_0-1600871496455.png

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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