Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago

How to reference a query (table)

Hi,

I have the following query which is also a table. I am thinking to use CALCULATE as a measure in Power BI report, but I don't know how to reference different row in the query by situation?

 



For example, when I create a measure called "2025 control budget", I would like combine two set of data, Actual cost data will come from a query which any cost before and include 2024 Dec data, then forecast cost data will come another query which will include cost info from Jan 2025 and onward. I plan to create four measures as listed under Name column.

Can you please provide me some suggestions? Thanks,

6 Replies

  • Hi Anonymous  - you can structure your measure for "2025 Control Budget"

     

    2025 Control Budget =
    VAR SelectedForecast = SELECTEDVALUE( 'YourTable'[Forecast] )
    RETURN
    CALCULATE(
    SUM( 'ActualCostTable'[Cost] ),
    'ActualCostTable'[Date] <= DATE(2024,12,31)
    ) +
    CALCULATE(
    SUM( 'ForecastCostTable'[Cost] ),
    'ForecastCostTable'[Date] >= DATE(2025,1,1)
    )

     

    replace with your table name, or the other measures (Prev Month -1 Forecast HCC, Prev Month Forecast HCC, Working Forecast), you can create similar measures but adjust the date filters accordingly.

     

    Hope this helps.