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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
meghapillai
Frequent Visitor

How to create a measure with a starting static value

I have a static actual value for April 2021 as 25.

I want to get the following months actual value using this static value.

Calculation is as below

For May-21, Actual value = Actual Value (April )+ Received Cost (May)-Cost of Sales (May )
50=25+35-10

 

Desired result is as below.

 Apr-21May-21Jun-21Jul-22
Received Cost40353050
Cost of Sales15101215
Actual Value255068103

 

 

How can I write to measure to calculate the following months actual value using just the April month value?
Cost of Sales and Received Cost are calculated using measures.

Sample pbix file link is provided in the link 

https://drive.google.com/file/d/1Y7hoL91B6jsGIqZvqt9JHpcyb6Lpv5Ui/view

1 ACCEPTED SOLUTION

First make a DAX column with this expression

 

EOM = EOMONTH('Table'[Date], 0)
 
And then use this measure to get your desired result.
mahoneypat_0-1646182249635.png

New =
VAR maxdate =
MAX ( 'Table'[EOM] )
VAR vSummary =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( 'Table', 'Table'[EOM] ),
"cTS", [Cost of Sales],
"cRC", [Received Cost]
),
ALL ( 'Table' ),
'Table'[EOM] <= maxdate
&& 'Table'[EOM] >= DATE ( 2021, 4, 30 )
)
RETURN
SUMX ( vSummary, [cRC] - [cTS] )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
VijayP
Super User
Super User

@meghapillai 
in powerQuery Editor , Unpivot The Data (only value columns)
in power bi report view 
Use this function
VAR ActualValue = Calcualte(Sum(Value),filter(table, Column = "ACtual"))

VAR CostValue = Calcualte(Sum(Value),filter(table, Column = "Cost of Sales"))

VAR ReceivedCost Value = Calcualte(Sum(Value),filter(table, Column = "Received Cost"))
Return
ActualValue+CostValue+ReceivedCostValue

you can drag that to Table or Matix to see the result




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Thanks for the suggestion. But my data structure is a bit different. Received Cost and Cost of Sales values are result of 2 measures. I'm attaching a sample file here. Please see if you can help on generating the actual value measure, taking static value for april as 25.

 

Desired result is as below

 Apr-21May-21Jun-21Jul-21
Received Cost40353050
Cost of Sales15101215
Actual Value255068103

 

https://drive.google.com/file/d/1Y7hoL91B6jsGIqZvqt9JHpcyb6Lpv5Ui/view?usp=sharing

First make a DAX column with this expression

 

EOM = EOMONTH('Table'[Date], 0)
 
And then use this measure to get your desired result.
mahoneypat_0-1646182249635.png

New =
VAR maxdate =
MAX ( 'Table'[EOM] )
VAR vSummary =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( 'Table', 'Table'[EOM] ),
"cTS", [Cost of Sales],
"cRC", [Received Cost]
),
ALL ( 'Table' ),
'Table'[EOM] <= maxdate
&& 'Table'[EOM] >= DATE ( 2021, 4, 30 )
)
RETURN
SUMX ( vSummary, [cRC] - [cTS] )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat  Thank you. This solved my problem. 🙂

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.