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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculated Measure for Yearly Cumulative % Across Months in a visual

Hey,

 

 

I have data from January to September of this year. I have a bar chart and would like a static line for the margin % for the whole year. I know how to do it for the entire company by creating a column, but then it doesn't change for drill downs. The issue is that I want it to change for the roles it is shared with. ie, I want the static line to be Region specific for the region it is shared with. I want the line to be District specific for the district I share with, not just the company margin. Please help. Thanks

3 ACCEPTED SOLUTIONS

@Anonymous

 

hello, to create a fixed margin:

 

Margin =
DIVIDE (
    CALCULATE (
        SUM ( Table1[Sales] ),
        ALLEXCEPT ( Table1, Table1[Region], Table1[District] )
    )
        - CALCULATE (
            SUM ( Table1[Cost] ),
            ALLEXCEPT ( Table1, Table1[Region], Table1[District] )
        ),
    CALCULATE (
        SUM ( Table1[Sales] ),
        ALLEXCEPT ( Table1, Table1[Region], Table1[District] )
    )
)



Lima - Peru

View solution in original post

Sean
Community Champion
Community Champion

@Vvelarde That works too - But why do we need the District?

 

Margin 2 = 
DIVIDE (
    CALCULATE (
        SUM ( Table1[Sales] ),
        ALLEXCEPT ( Table1, Table1[Region] )
    )
        - CALCULATE (
            SUM ( Table1[Cost] ),
            ALLEXCEPT ( Table1, Table1[Region] )
        ),
    CALCULATE (
        SUM ( Table1[Sales] ),
        ALLEXCEPT ( Table1, Table1[Region] )
    )
)

 

EDIT: You can actually revise mine to only this as well

 

Margin_Region = 
VAR RegionSales =
    CALCULATE ( SUM ( Table1[Sales] ), ALLSELECTED(Table1[Month]) )
VAR RegionCost =
    CALCULATE ( SUM ( Table1[Cost] ), ALLSELECTED(Table1[Month]) )
RETURN
DIVIDE ( RegionSales - RegionCost, RegionSales )

 

View solution in original post

Sean
Community Champion
Community Champion

@Anonymous Actually the more I test this the more I think you should go with this....

 

Margin_Region ALS = 
VAR RegionSales =
    CALCULATE ( SUM ( Table1[Sales] ), ALLSELECTED(Table1[Month]) )
VAR RegionCost =
    CALCULATE ( SUM ( Table1[Cost] ), ALLSELECTED(Table1[Month]) )
RETURN
DIVIDE ( RegionSales - RegionCost, RegionSales )

Look the picture - you can test this with a matrix visualization - I think the above will give you what you are looking for

If you use Slicers andd a Month Slicer and select only a number of months this will adjust

 

% Margin per Region ALLSELECTED.png

View solution in original post

14 REPLIES 14

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.