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!
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
__result
Best Regards,
Gao
Community Support Team
If 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
Thanks this worked.