Forum Discussion
Dax Formula correction help
- 7 months ago
Hello! The issue lies in your tot_val variable. By using ALL(Inventory_stock_dtl), you are telling Power BI to ignore every single filter on that table, which is why your Division, Category, and Item filters are being ignored.
To calculate the total across all aging buckets while keeping your other slicers active, you should replace ALL with ALLEXCEPT or specifically remove the filter only from the Ageing Bucket column.
Try updating your tot_val variable to this:
var tot_val =
CALCULATE(
SUM(Inventory_stock_dtl[Value]),
ALLEXCEPT(
Inventory_stock_dtl,
Inventory_stock_dtl[Stock_fin_year],
Inventory_stock_dtl[Month_sorter],
Inventory_stock_dtl[div_name],
Inventory_stock_dtl[item_category],
Inventory_stock_dtl[item
]
)
)
Alternatively, a cleaner way using REMOVEFILTERS:
var tot_val =
CALCULATE(
SUM(Inventory_stock_dtl[Value]),
REMOVEFILTERS(Inventory_stock_dtl[Ageing_Bucket_Column_Name]), -- Replace with your actual bucket column name
Inventory_stock_dtl[Stock_fin_year] = FinalYear,
Inventory_stock_dtl[Month_sorter] = FinalMo
nth
)
Why this works:
ALLEXCEPT: It clears all filters except for the ones you list. By listing Year, Month, Division, and Category, those filters stay active while the "Ageing Bucket" filter is cleared to get the grand total.
REMOVEFILTERS: This is the modern way. It only removes the filter from the specific "Ageing Bucket" column, allowing all other slicers (Division, Item, etc.) to continue affecting the total.
I hope this helps you get that 100% total! If this resolves your issue, please mark this post as an "Accepted Solution." Happy New Year!
Best regards,
Vishwanath
Hi JothiG
Okay, could you please let us know the exact logic and the output you want to view from the visual.
If you can provide the sample data, that would be helpful.
| Div_name | Category | Category sorter | Item | item_sorter | Item_type | Stock_fin_year | Stock_year | Stock_month | Stock_month_name | Month_sorter | Period | period_sorter | Value | Ageing_bucket | Ageing_bucket_sorter |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 8104.15 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 21104.72 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 28478.02 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 146531.79 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 364557.7 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 34984.5 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 9755.35 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 17059.41 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 17193.76 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 12369.36 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 1968.73 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 1175.36 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 2827.62 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 1560.06 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 14625.6 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 1669.77 | 0-60 Days | 1 |
| HO | RM | 1 | Yarn At warehouse | 1 | At WH | 2025 | 2025 | 4 | Apr | 4 | Q1 | 1 | 683.53 | 0-60 Days | 1 |
Logic :
Visual : Area Chart
X -Axis : Fin Year
Y-Axis : Percentage of Ageing_Bucket
Legend : Ageing Bucket
Y -Axis shows Ageing bucket (Eg: 0-30 Days,31-60 Days etc) and the ageing bucket percentage shows inside area chart: now i want calculate percentage = (single ageing bucket value/ All Ageing bucket value) *100 . sum of all ageing bucket percentage should be 100.
- krishnakanth2407 months agoSuper User
Hi JothiG
1)Total Stock Value =
SUM ( 'Stock'[Value] )2)Ageing Bucket % =
DIVIDE(
[Total Stock Value],
CALCULATE(
[Total Stock Value],
ALL ( 'Stock'[Ageing_bucket] )
),
0
)Numerator → Stock value for current ageing bucket
Denominator → Total stock value across all ageing buckets
ALL(Ageing_bucket) removes only bucket filter
Result = percentage contribution
Sum of all buckets = 100%Area Chart
X-Axis → Stock_fin_year
Y-Axis → Ageing Bucket %
Legend → Ageing_bucket
Data labels → ON (Percentage)- JothiG7 months agoHelper III
still not getting correct result.
- krishnakanth2407 months agoSuper User
Hi JothiG
Okay, can you confirm the columns that are referencing from each table and the relationships between the tables.