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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
djallarii
Helper I
Helper I

I need help figuring out which ALL() filter logic will produce the results I need

Source Table  
v_campus_volume[name]v_campus_volume[fiscal_year]v_campus_volume[volume]
Campus 12021743
Campus 22021573
Campus 32021455
Campus 42021545
Campus 12022

566

 

 

Campus 22022554
Campus 32022288
Campus 42022516

 

 

Dimension Table 
dim_campus[name]dim_campus[sort_order]
Campus 199
Campus 21
Campus 31
Campus 41
Network89

 

 

Current Output  
dim_campus[name]dim_date[fiscal_year]Sum of Total Volume
Campus 22021573
Campus 22022554
Campus 32021455
Campus 32022288
Campus 42021545
Campus 42022516
Network2021 
Network2022 
Campus 12021743
Campus 12022566

 

Desired Output  
dim_campus[name]dim_date[fiscal_year]Sum of Total Volume
Campus 22021573
Campus 22022554
Campus 32021455
Campus 32022288
Campus 42021545
Campus 42022516
Network20212316
Network20221924
Campus 12021743
Campus 12022566

 

 

Current measure:
Total Volume = CALCULATE ( SUM ( v_campus_volume[volume] ) )

 

Where I'm at but I can't figure out which ALL combo to use to get it to work right... I've only been able to get a total from the entire dataset to return anything.

 

Total Volume =
VAR __SelectedCampus =
SELECTEDVALUE ( dim_campus[name] )
RETURN
IF (
__SelectedCampus = "Network",
CALCULATE ( SUM ( v_campus_volume[volume] ), ALL ( dim_campus ) ),
CALCULATE ( SUM ( v_campus_volume[volume] ) )
)



2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @djallarii,

 

I tested your measure and the results are as follows.

vtangjiemsft_1-1706496176652.png

 

vtangjiemsft_0-1706496164856.png

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.

 

Best Regards,

Neeko Tang

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

123abc
Community Champion
Community Champion

It looks like you are trying to calculate the Total Volume based on different conditions, and you want to handle the "Network" case differently. To achieve the desired output, you need to adjust the context transition in your DAX formula.

You can use the following modified measure to achieve the desired output:

 

Total Volume =
VAR __SelectedCampus = SELECTEDVALUE(dim_campus[name])

RETURN
IF (
__SelectedCampus = "Network",
CALCULATE (
SUM ( v_campus_volume[volume] ),
ALL ( dim_campus[name] ),
VALUES ( dim_campus[sort_order] )
),
CALCULATE ( SUM ( v_campus_volume[volume] ) )
)

 

Explanation:

  1. For the "Network" case, you use CALCULATE with ALL ( dim_campus[name] ) to remove the filter context on the campus name. Additionally, you use VALUES ( dim_campus[sort_order] ) to maintain the sort order in the result.

  2. For other campuses, you simply calculate the sum of the volume without altering the filter context.

This should give you the desired output where the "Network" rows show the sum across all campuses and years.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors