Forum Discussion

meghapillai's avatar
meghapillai
Frequent Visitor
4 years ago
Solved

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

  • mahoneypat's avatar
    mahoneypat
    4 years ago

    First make a DAX column with this expression

     

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

    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

4 Replies

  • VijayP's avatar
    VijayP
    Icon for Community Champion rankCommunity Champion

    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

    • meghapillai's avatar
      meghapillai
      Frequent Visitor

      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

      • mahoneypat's avatar
        mahoneypat
        Icon for Microsoft Employee rankMicrosoft Employee

        First make a DAX column with this expression

         

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

        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