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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Dynamic total sum by dimension

Hi everyone,

 

Hope you guys fine and safe.

 

Here is my thing, I want a dynamic total sum based on two dimensions (Continent and Country). 

What I want is when I switch dimensions it gives me the total sum of the selected dimension. 

For now I know how to do it but not dynamically : 

Dynamic Total sales = CALCULATE(SUM('Requête1'[Sales]),ALL('Requête1'[Country]))
I have to put rather country or  continent but of course when I switch dimensions it does not make sense anymore.
 
Is it possible to do it dynamically ?
 
 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Thanks @amitchandak 

 

Here is the thing, when I am at a continent level granularity I want the total sum of all continent like this below: Capture1.JPG

 

and when I am at a country level I want the sum to perform like this : 

Capture2.JPG

 

Hope this make it clear enough,

 

Thanks a lot for your time

 

 

View solution in original post

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

Dynamic Total sales =
SWITCH (
    TRUE (),
    ISFILTERED ( 'Requête1'[Country] ),
        CALCULATE (
            SUM ( 'Requête1'[Sales] ),
            ALLEXCEPT ( 'Requête1', 'Requête1'[Continent] )
        ),
    ISFILTERED ( 'Requête1'[Continent] ), CALCULATE ( SUM ( 'Requête1'[Sales] ), ALL ( 'Requête1'[Country] ) )
)

 

 

Best regards

Icey

 

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks @amitchandak 

 

Here is the thing, when I am at a continent level granularity I want the total sum of all continent like this below: Capture1.JPG

 

and when I am at a country level I want the sum to perform like this : 

Capture2.JPG

 

Hope this make it clear enough,

 

Thanks a lot for your time

 

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

Dynamic Total sales =
SWITCH (
    TRUE (),
    ISFILTERED ( 'Requête1'[Country] ),
        CALCULATE (
            SUM ( 'Requête1'[Sales] ),
            ALLEXCEPT ( 'Requête1', 'Requête1'[Continent] )
        ),
    ISFILTERED ( 'Requête1'[Continent] ), CALCULATE ( SUM ( 'Requête1'[Sales] ), ALL ( 'Requête1'[Country] ) )
)

 

 

Best regards

Icey

 

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

amitchandak
Super User
Super User

@Anonymous , Not very clear. If you want a Grand total by any of these. Unless there is null value all(Sales), all(Country), or all(Continent) will give same value

 

If you want to change axis. Refer to :

Dynamically change chart axis in Power BI
https://www.youtube.com/watch?v=6jeSIRpjv0M
https://datamonkeysite.com/2020/10/22/change-dimension-dynamically-using-parameter-in-powerbi/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.