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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Saloni_Gupta
Helper I
Helper I

Calculated table with Dimensions and Measures from different tables

Hi All,
I want to have data in this format (along with WeekId's):

Saloni_Gupta_0-1705468878535.png

I am trying to create a calculated table using the below dax:

var Actual = CALCULATE([Actual Hours], ('Week Table'), 'Week Table'[YTD Flag] = "Y")
var Budget = CALCULATE([Budget Hours], ('Week Table'), 'Week Table'[YTD Flag] = "Y")
RETURN
SUMMARIZE('Job Hour Details',
'Management Level'[Name],
'Week Table'[Week Index],
"Variance",[Variance Hours to Budget],
"ActualsOrBudget",
SWITCH(TRUE(),"Actual",Actual,"Budget",Budget)
)
but this does not work as Switch function does not support comparing values of type True/False with text.
Can you suggest how to fix this dax?

Thanks in Advance!
3 REPLIES 3
DataInsights
Super User
Super User

@Saloni_Gupta,

 

Try this calculated table. I replaced the first argument in your SWITCH expression with the column to evaluate.

 

CalculatedTable =
VAR Actual =
    CALCULATE ( [Actual Hours], ( 'Week Table' ), 'Week Table'[YTD Flag] = "Y" )
VAR Budget =
    CALCULATE ( [Budget Hours], ( 'Week Table' ), 'Week Table'[YTD Flag] = "Y" )
RETURN
    SUMMARIZE (
        'Job Hour Details',
        'Management Level'[Name],
        'Week Table'[Week Index],
        "Variance", [Variance Hours to Budget],
        "ActualsOrBudget", SWITCH ( YourTableName[BudgetORActual], "Actual", Actual, "Budget", Budget )
    )

 





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

Proud to be a Super User!




Hi @DataInsights ,
Thanks for replying on the post. 
I think I haven't made it clear that the column "BudgetOrActual" does not exist yet in any of my tables and this is what I am trying to achieve with the Switch() in this DAX to create a new column with values "Actual" or "Budget" and another column which shows the corresponding value for Actual or Budget. 
I also tried this way:

var _MeasureName = {"Actual","Budget"}
var Actual = CALCULATE([Actual Hours], ('Week Table'), 'Week Table'[YTD Flag] = "Y")
var Budget = CALCULATE([Budget Hours], ('Week Table'), 'Week Table'[YTD Flag] = "Y")
RETURN
SUMMARIZE('Job Hour Details',
'Management Level'[Name],
'Week Table'[Week Index],
"Variance",[Variance Hours to Budget],
"ActualOrBudget",
SWITCH(_MeasureName,"Actual",Actual,"Budget",Budget)
)
and this gives me "A table of multiple values was supplied where a single value was expected." error

@Saloni_Gupta,

 

Would you be able to provide sample data for each table (not a screenshot)? Also, would you provide an example of the expected result for each column (only three columns are in your screenshot)?

 

One idea is to use the UNION function to combine two individual table expressions: one for Actual, and one for Budget. This would allow you to hardcode "Actual" or "Budget" in the individual table expressions and avoid using SWITCH.





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

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors