cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dd-edwin
Frequent Visitor

How to reference column names dynamically to change Y value in line graph?

Hello,

 

I am working through the following tips and tricks video: https://youtu.be/i1kCHZEhnEY?t=1539 and have a question about dynamic metrics.

 

In his example, he is able to switch between Cost, Revenue, etc.

I want to add another slicer that will change the Y Axis values from one column to another.

 

Ex)
Average Type TableAverage Type TableDashboardDashboardData TableData Table

Quantity Type TableQuantity Type Table

 

selected_measure = 
    var temp_key = SWITCH(
            TRUE(),
            "Kit Quantity" IN ALLSELECTED(QuantityTypeTable[Quantity Type]), "Kit Quantity",
            "Unit Quantity" IN ALLSELECTED(QuantityTypeTable[Quantity Type]), "Unit Quantity",
            // Default
            "Kit Quantity"
    )

    RETURN
        SWITCH(
            TRUE(),
            SWITCH(
                TRUE(),
                "Actual" IN ALLSELECTED(AveragingTypeTable[Averaging Type]), CALCULATE(SUM('DataTable'[temp_key])),

                // Pretend the rolling average calculates the rolling average...
                "Rolling Average" IN ALLSELECTED(AveragingTypeTable[Averaging Type]), CALCULATE(SUM('DataTable'[temp_key])),
                CALCULATE(0)
            )
        )

I want to be able to use a dynamic column so that I can use one LINE GRAPH and switch between the kit/unit quantity and the type of Y values (based on averaging or actual values).

 

How do I make my calculation function dynamic such that it takes temp_key and uses that string as the column name in DataTable (for the red text)?

 

Thanks!

0 REPLIES 0

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors