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
smartp121
New Member

Need help on a Row level data Calculation

Hi Friends,


I need some help with this calculation, Don't know how to make this work

 

I have data in the following format 

 

YearMonthRevenue MTD Revenue 
20204  489,611 
20205  308,211             31,404
20206  277,696                  991
20207  277,696             20,907
20208  284,882             28,899
20209  274,322               5,106

 

The MTD Revenue calculation should be like Month month 5 - Month 4 = month 5 MTD, similar to the remaining months.

 

please help me with this calculation.

11 REPLIES 11
v-yangliu-msft
Community Support
Community Support

Hi   @smartp121 ,

 

It should have nothing to do with TotalDirectRevenue. This error is mainly EARLIER('Projects’[Revenue Month]), Parameter is not the correct type.

 

You can see whether MTD_Revee uses a calculated column or a measure, because the EARLIER function cannot be used for measure, and an error will occur

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yangliu-msft
Community Support
Community Support

Hi  @smartp121,

 

Are you using a calculated column or a measure?

For measure, it is not possible to use the earlier function

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yangliu-msft ,

 

The column Projects'[TotalDirectRevenue] is coming from the DB, I renamed it to PTD Direct Revenue Recognized at the report level,

 

it's not a measure or calculated column

 

its Datatype in the DB is Float 

 

 

 

v-yangliu-msft
Community Support
Community Support

Hi  @smartp121 ,

 

Here are the steps you can follow:

1. Create calculated column.

MTD_Revenue =
var _mtd=
CALCULATE(SUM('Table (2)'[PTD Direct Revenue Recognized]),FILTER('Table (2)','Table (2)'[Month]=EARLIER('Table (2)'[Month])))
-
CALCULATE(SUM('Table (2)'[PTD Direct Revenue Recognized]),FILTER('Table (2)','Table (2)'[Month]=EARLIER('Table (2)'[Month])-1))

return IF('Table (2)'[Month]=4,'Table (2)'[PTD Direct Revenue Recognized],_mtd)
MTD_HXC =
var _mtd=
CALCULATE(SUM('Table (2)'[PTD HxC]),FILTER('Table (2)','Table (2)'[Month]=EARLIER('Table (2)'[Month])))
-
CALCULATE(SUM('Table (2)'[PTD HxC]),FILTER('Table (2)','Table (2)'[Month]=EARLIER('Table (2)'[Month])-1))

return IF('Table (2)'[Month]=4,BLANK(),_mtd)

2. Result.

v-yangliu-msft_0-1605073402190.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-yangliu-msft  (Liu)

 

Thanks for the calculation , I'm getting below error, any help pls 

 

smartp121_0-1605076766751.png

 

v-yangliu-msft
Community Support
Community Support

Hi  @smartp121 ,

 

According to your calculation rules, The MTD Revenue calculation should be like Month month 5-Month 4 = month 5 MTD.

 

The situation should look like the following table:

v-yangliu-msft_0-1605058027731.png

 

For example, May’s MTD Revenue should be -181400, but your MTD Revenue is 31404.

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yangliu-msft 

 

smartp121_0-1605072941103.png

 

you can see the calculation in the fig above 

 

MTD Revenue is D7-D6 and I need to calculate MTD Revenue column, ( Column J)

 

 

smartp121
New Member

Hi @camargos,

 

sorry, I missed explaining something,

 

Column D should be my Result 

 

This report has a filter on Year so when I put a filter on Year the Column D should populate automatically based on calculation.

 

YearMonthRevenue MTD Revenue 
20204  489,611 
20205  308,211             31,404
20206  277,696                  991
20207  277,696             20,907
20208  284,882             28,899
20209  274,322               5,106
camargos88
Community Champion
Community Champion

@smartp121 ,

 

Check the attached file.

 

Capture.PNG



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

Proud to be a Super User!



camargos88
Community Champion
Community Champion

@smartp121 ,

 

Can you explain more the logic here ? 



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

Proud to be a Super User!



@camargos88  the issue is to identify the calculation logic to calculate the MTD Revenue, 

 

The MTD Revenue of Month 5  = Reven of Month 5 - Revenue of Month 6

 

how do I put this together in a calculation how to subtract row data ?

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.