The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi All,
I want to have data in this format (along with WeekId's):
I am trying to create a calculated table using the below dax:
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 )
)
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:
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.
Proud to be a Super User!