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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors