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
theonexcent
Frequent Visitor

Doing calculation only at one hierarchy level

I want to display the sum (higlighted in green) only on the line higlighted in yellow. Is there any way of just doing the calculation at this level and displaying it without it going to higher/lower row levels?Screenshot 2023-06-26 085207.png

 

Edit: Noticed I probably should've added some context. Here is what I have come up with so far, using this formula 

 

Cost Labor =
Var TA = SELECTEDVALUE(TrackingAccountsHierarchy[TrackingAccountIDDescription])
RETURN  
SUMX(ActualCost,CALCULATE(ActualCost[Cost Act], TrackingAccountsHierarchy[CostType]="L"))

 

Screenshot 2023-06-26 091833.png

 

I really just need it to output at the yellow line level. Hopefully someone has had this same request out there. 

 

Edit 2: Figured out something else now and I just want to keep updating my post just incase someone out there ever has this issue.

 

Screenshot 2023-06-26 142133.png

 

I still have not figured out how to get the $41,702 only to that specific hierachy level but, if you notice, I was able to get the 36.07 to just that hierarchy. 

 

Here is how I accomplished that:

 

(Formula for number higlighted in red)

 

Q/MH = DIVIDE([Cost Qty Act], [MH Act])
 
Other formulas that are involved in this formula:
 
Cost Qty Act =
VAR ta = SELECTEDVALUE(TrackingAccountsHierarchy[TrackingAccountIDDescription])
RETURN
CALCULATE(SUMX(ActualCost,CALCULATE(sum(ActualCost[CostQuantity]), TrackingAccountsHierarchy[CostType]="I")), ta = TrackingAccountsHierarchy[TrackingAccountIDDescription])
 
MH Act = SUMX(ActualCost, CALCULATE(SUM(ActualCost[RT]) + SUM(ActualCost[OT]) + SUM(ActualCost[DT]), TrackingAccountsHierarchy[CostType]="L"))
 
What I have concluded is that when the cost types are assigned in the original formulas, the third formula will then only output at the hiearchal level. I am in no way a DAX expert so if anyone can explain to me why this happens, that would be great.
 
Still trying to figure out how to get the $41,702 to the yellow line only within the original formula. 
 
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @theonexcent ,

You can create another new measure as below and put this new measure to replace the measure [Cost Labor] on the matrix:

Meascure =
IF (
    ISINSCOPE ( 'TrackingAccountsHierarchy'[TrackingAccountIDDescription] )
        && NOT ( ISINSCOPE ( 'TrackingAccountsHierarchy'[CostType] ) ),
    Meascure =
IF (
    ISINSCOPE ( 'TrackingAccountsHierarchy'[TrackingAccountIDDescription] )
        && NOT ( ISINSCOPE ( 'TrackingAccountsHierarchy'[CostType] ) ),
    [Cost Labor],
    BLANK ()
),
    BLANK ()
)

If the above one can't help you, please provide some raw data in your table  'TrackingAccountsHierarchy' and 'ActualCost' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? By the way, is there any relationship between these two tables? If yes, please provide the related info. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @theonexcent ,

You can create another new measure as below and put this new measure to replace the measure [Cost Labor] on the matrix:

Meascure =
IF (
    ISINSCOPE ( 'TrackingAccountsHierarchy'[TrackingAccountIDDescription] )
        && NOT ( ISINSCOPE ( 'TrackingAccountsHierarchy'[CostType] ) ),
    Meascure =
IF (
    ISINSCOPE ( 'TrackingAccountsHierarchy'[TrackingAccountIDDescription] )
        && NOT ( ISINSCOPE ( 'TrackingAccountsHierarchy'[CostType] ) ),
    [Cost Labor],
    BLANK ()
),
    BLANK ()
)

If the above one can't help you, please provide some raw data in your table  'TrackingAccountsHierarchy' and 'ActualCost' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? By the way, is there any relationship between these two tables? If yes, please provide the related info. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

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.