Forum Discussion
Need help please to sum and filter based on different value criteria from the same column
- Anonymous1 year ago
Hi DanPell ,
I see. I assume the user is in the southern hemisphere to observe the seasons. You can hard-code the country code into the measure:
MEASURE = VAR __N_countries = { "US" } VAR __curr_selected_value = SELECTEDVALUE ( 'Table'[Campaign Name] ) VAR __result = SWITCH ( TRUE (), ISBLANK ( __curr_selected_value ), SUM ( 'Table'[Campaign Targets] ), __curr_selected_value = "Spring Sale", CALCULATE ( SUM ( 'Table'[Campaign Targets] ), NOT 'Table'[Country Code] IN __N_countries ) + CALCULATE ( SUM ( 'Table'[Campaign Targets] ), 'Table'[Campaign Name] = "Autumn Sale", 'Table'[Country Code] IN __N_countries ), __curr_selected_value = "Autumn Sale", CALCULATE ( SUM ( 'Table'[Campaign Targets] ), NOT 'Table'[Country Code] IN __N_countries ) + CALCULATE ( SUM ( 'Table'[Campaign Targets] ), 'Table'[Campaign Name] = "Spring Sale", 'Table'[Country Code] IN __N_countries ) ) RETURN __resultBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
- 1 year ago
Hey thanks for this, awesome. Just a quick one if I have multiple Northern Hem countries (i.e. US, CA, UK,) is that as easy as putting the respective country codes into the VAR measure i.e.
VAR__N_Countries = {"US","CA","UK"}??
Thanks!
Create a Measure:
CampaignSalesTargets =
VAR SelectedCampaign =
SELECTEDVALUE ( 'Table'[Campaign Name] )
RETURN
SWITCH (
TRUE (),
SelectedCampaign = "Spring Sale",
SUM ( 'Table'[Sales Targets_AU] ) + SUM ( 'Table'[Sales Targets_NZ] )
+ CALCULATE (
SUM ( 'Table'[Sales Targets_USA] ),
'Table'[Campaign Name] = "Autumn Sale"
),
SelectedCampaign = "Autumn Sale",
SUM ( 'Table'[Sales Targets_AU] ) + SUM ( 'Table'[Sales Targets_NZ] )
+ CALCULATE (
SUM ( 'Table'[Sales Targets_USA] ),
'Table'[Campaign Name] = "Spring Sale"
),
BLANK () // Default case if no campaign is selected
)
This should resolve your filtering issue and provide accurate results in your dashboard.
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Thanks mate, I have resolved the problem.