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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
PBI_newuser
Post Prodigy
Post Prodigy

Incorrect calculation with blank sum

Hi, I have a measure to calculate the Volume Impact. But it is incorrect when the [Volume Sum] is blank. 

If the [Volume Sum] is blank, it should be set as 0.

For example, Product A in 2020-10, the Volume Impact should be (0-1)*313 = -313 but it shows 395 which is incorrect.

The [Volume Impact Total] should has the same value as [Revenue YoY] for those lines highlighted in red.

How to fix the measure? Here is the pbix file.

 

PBI_newuser_0-1640072229385.png

 

1 ACCEPTED SOLUTION

Hi,

Try these measures

Measure = ([Volume Sum]-[Volume last year])*[AUSP Last Year]
Measure 2 = if(HASONEFILTER('Calendar'[YearMonth]),[Measure],sumx(summarize('Calendar','Calendar'[YearMonth],"ABCD",[Measure]),[ABCD]))

The Grand total does not match but am unable to find out my mistake.

Hope this helps.

Untitled.png


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

View solution in original post

7 REPLIES 7
MFelix
Super User
Super User

HI @PBI_newuser 

 

This is related with the fact that the values are blank has you refer you can do one of two things for the  Volume Last Year metrics to be 0  in the measure it self or within the other metric.

 

To force the metric it self change it to:

Volume last year = CALCULATE([Volume Sum],SAMEPERIODLASTYEAR('Calendar'[Date])) + 0

 

This however makes the measure to be always 0 and not blank so will present on other rows that you may not want it.

 

The second option is to redo your Total volume to the following:

Volume Impact = 
var TotalSalesCalculation =[Volume Last Year] + 0
Return
  IF (
    MIN ( 'Calendar'[Date] ) > MAX ( 'Append Table'[Date] ),
    CALCULATE (
        SUMX (
            SUMMARIZE ( 'Append Table', 'Calendar'[YearMonth] ,'Append Table'[Product]),
            IF (
                TotalSalesCalculation <= 0,
                ( [Revenue] - [Revenue Last Year] ),
                ( [Volume Sum] - TotalSalesCalculation ) * [AUSP Last Year]
            )),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
    )*-1,
    SUMX (
        SUMMARIZE ( 'Append Table', 'Calendar'[YearMonth],'Append Table'[Product] ),
        IF (
            TotalSalesCalculation <= 0,
            ( [Revenue] - [Revenue Last Year] ),
            ( [Volume Sum] - TotalSalesCalculation  ) * [AUSP Last Year]
        ) ))

Has you can see we are calculation the Volume Last Year and adding the 0 so them you can compare it and get expected result.

 

MFelix_0-1640267697348.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix , thank you for the modified measures. After applying the suggested measures, the value doesn't seem correct too. [Volume Impact] for product A supposed to have same value as [Revenue YoY].

 

PBI_newuser_0-1640330441409.png

Did you do + 0 or =0


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix , yes, I have modified the measures based on your suggestion. I am not sure which part is incorrect, would you mind to take a look at it? Here is the pbix file.

PBI_newuser_0-1640569851358.png

 

Access Denied message.


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

Hi,

Try these measures

Measure = ([Volume Sum]-[Volume last year])*[AUSP Last Year]
Measure 2 = if(HASONEFILTER('Calendar'[YearMonth]),[Measure],sumx(summarize('Calendar','Calendar'[YearMonth],"ABCD",[Measure]),[ABCD]))

The Grand total does not match but am unable to find out my mistake.

Hope this helps.

Untitled.png


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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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