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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Create measure to calculate target

Hello,

 

I have a targets table for which I want to use to implement a bit of complicated logic for displaying targets. A sample of the table below. Each country has a number of products and customers. I want the target value to be displayed based on my selections. For example in the below. If I select nothing, the target should be 100 as it is the highest level in the hierarchy and it is the country target, if I select product1 it will show the target for PRODUCT1 and same thing if I select PRODUCT2.

 

 

  Date  Country  Product  Customer  Country_Hierarchy_Depth  Product_Hierarchy_Depth  Customer_Hierarchy_Depth  Target
Sep-23  US  ALL  ALL  2  2  2  100
Sep-23  US  PRODUCT1  ALL  2  1  2  150
Sep-23  US  PRODUCT2  ALL  2  1  2  150
Sep-23  US  PRODUCT3  ALL  2  1  2  150
Sep-23  US  PRODUCT1  STORE  2  1  1  120
Sep-23  US  PRODUCT2  STORE  2  1  1  120
Sep-23  US  PRODUCT3  STORE  2  1  1  120

 

Now in case I select PRODUCT1 and PRODUCT2 together, it should show me the target for the country which is 100 (and not for example the min and max of either products). Same thing if I select PRODUCT1 and PRODUCT2 and STORE, I need to see the total country also (100), but of course if I select PRODUCT1 and STORE it will automatically be 120.

 

I also created a calculated column to sum the hierarchy depths of the 3 columns (if this could be of any help), tried using it with MAX function but didnt get anywhere.

 

Any help on how I can tackle this?

 

Thank you!!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Create a disconnected table with

 

Prd = distinct( Table[Product])

 

Then create a measure

M1=

var _sel  = calculate(isfiltered(Prd[Product]), allselected())

return

if(_sel, calculate(Sum(Table[Target]), filter(Table, Table[Proudct] in values(Prd[Product]))) , calculate(Sum(Table[Target]), filter(Table, Table[Proudct] ="All")))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Create a disconnected table with

 

Prd = distinct( Table[Product])

 

Then create a measure

M1=

var _sel  = calculate(isfiltered(Prd[Product]), allselected())

return

if(_sel, calculate(Sum(Table[Target]), filter(Table, Table[Proudct] in values(Prd[Product]))) , calculate(Sum(Table[Target]), filter(Table, Table[Proudct] ="All")))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

that did it! thanks a lot

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.