cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RomainH Frequent Visitor
Frequent Visitor

Measure sum problem

Spoiler
 

Hello,

 

Maybe you can help me ?

 

I have two tables in my model. One for command and one for product repository.

 

FT_COMMAND

Command_NumberLineArticleQtyTotal_Price
C000110A0001210
C000120A000236
C000130A0003120
C000210A00011050

 

DIM_ARTICLES

ArticleFamilyPrice_ex_works
A0001AAA2
A0002AAA1
A0003BBB4

 

So, I am trying to measure the % margin of each family. I have two different measures :

- Total_Price_ex_works = calculate(SUM(DIM_ARTICLES[Price_ex_works])*SUM(FT_COMMAND[Qty]))

- % Margin = FORMAT((sum(FT_COMMAND[Total_Price])-(sum(DIM_ARTICLES[Price_ex_works])*sum(FT_COMMAND[Qte])))/sum(FT_COMMAND[Total_Price]);"Percent")

 

But when I build a table I have this result :

 

FamillyArticleTotal_PriceQtéPrice_ex_worksTotal_Price_ex_works % Margin
AAAA0001601222460%
AAAA0002631350%
TOTAL AAA 661534532%

 

But i should have :

 

FamillyArticleTotal_PriceQtéPrice_ex_worksTotal_Price_ex_works % Margin
AAAA0001601222460%
AAAA0002631350%
TOTAL AAA 66  2759%

 

The problem is, the system is suming the total, but it shouldn't.

 

I hope you can help me, i'm starting on Power BI, and unfortunately some basic function are hard for me to use.

 

Thank you.

 

Regards,

RomainH

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Measure sum problem

Hi @RomainH,

 

You'd better create the calculated column in table DIM_ARTICLES to calculate the Total_Price_ex_works with the formula below.

 

Column =
CALCULATE ( SUM ( 'FT_COMMAND'[Qty] ) * SUM ( 'DIM_ARTICLES'[Price_ex_works] ) )

Then you could create the measure like this.

% Margin =
FORMAT (
    DIVIDE (
        CALCULATE ( SUM ( 'FT_COMMAND'[Total_Price] ) )
            - CALCULATE ( SUM ( 'DIM_ARTICLES'[Total_Price_ex_works] ) ),
        CALCULATE ( SUM ( 'FT_COMMAND'[Total_Price] ) )
    ),
    "Percent"
)

Here is the output.

result.PNG

 

 

Hope this can help you!

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Community Support Team
Community Support Team

Re: Measure sum problem

Hi @RomainH,

 

You'd better create the calculated column in table DIM_ARTICLES to calculate the Total_Price_ex_works with the formula below.

 

Column =
CALCULATE ( SUM ( 'FT_COMMAND'[Qty] ) * SUM ( 'DIM_ARTICLES'[Price_ex_works] ) )

Then you could create the measure like this.

% Margin =
FORMAT (
    DIVIDE (
        CALCULATE ( SUM ( 'FT_COMMAND'[Total_Price] ) )
            - CALCULATE ( SUM ( 'DIM_ARTICLES'[Total_Price_ex_works] ) ),
        CALCULATE ( SUM ( 'FT_COMMAND'[Total_Price] ) )
    ),
    "Percent"
)

Here is the output.

result.PNG

 

 

Hope this can help you!

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Super User IV
Super User IV

Re: Measure sum problem

Hi,

 

You may download my solution PBI file from here.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
RomainH Frequent Visitor
Frequent Visitor

Re: Measure sum problem

Hello, thank you so much, it works !

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors