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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tvadoc
Frequent Visitor

Different measure selectors on diagrams

Hello,

 

The dataset is about surveys where PID is assigned to one study, and cycle time is a difference between 2 milestones expressed in days/weeks/months. In some cases, the survey started within that study (PID), but hasn't finished, hence the null values:

tvadoc_0-1666694951153.png

 

 

Basically, I'd like to make 2 slicers that changes the values on that diagram based on my selection.

 

First is a Measure selector, where it shows either Average, Minimum or Maximum

Second is a Date selector, where it shows either Cycle Days, Cycle Weeks or Cycle Months:

tvadoc_0-1666694638992.png

 

 

So far, what I did, is I created lot of switch cases, where it looks to see what is your choice in the time span and measue selector selection.

 

Time span selection = SWITCH( TRUE(),
AND(VALUES('Time span selector'[Time span selector]) = "Day", VALUES('Measure selector'[Measure selector]) = "Avg"), AVERAGE(final[Cycle time - DAYS]),
AND(VALUES('Time span selector'[Time span selector]) = "Week", VALUES('Measure selector'[Measure selector]) = "Avg"), AVERAGE(final[Cycle time - WEEKS]),
AND(VALUES('Time span selector'[Time span selector]) = "Month", VALUES('Measure selector'[Measure selector]) = "Avg"), AVERAGE(final[Cycle time - MONTHS]),
AND(VALUES('Time span selector'[Time span selector]) = "Day", VALUES('Measure selector'[Measure selector]) = "Min"), MIN(final[Cycle time - DAYS]),
AND(VALUES('Time span selector'[Time span selector]) = "Week", VALUES('Measure selector'[Measure selector]) = "Min"), MIN(final[Cycle time - WEEKS]),
AND(VALUES('Time span selector'[Time span selector]) = "Month", VALUES('Measure selector'[Measure selector]) = "Min"), AVERAGE(final[Cycle time - MONTHS]),
AND(VALUES('Time span selector'[Time span selector]) = "Day", VALUES('Measure selector'[Measure selector]) = "Max"), AVERAGE(final[Cycle time - DAYS]),
AND(VALUES('Time span selector'[Time span selector]) = "Week", VALUES('Measure selector'[Measure selector]) = "Max"), AVERAGE(final[Cycle time - WEEKS]),
AND(VALUES('Time span selector'[Time span selector]) = "Month", VALUES('Measure selector'[Measure selector]) = "Max"), AVERAGE(final[Cycle time - MONTHS]),
BLANK())

 

And what I'd like to achieve, is a diagram, where it shows something like this:

tvadoc_2-1666694796488.png

 

A clustered column chart that shows the difference for each surveys based on time span and measure selection.

 

How should I do this? Is the code I written seems okay?

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @tvadoc ,

I have created a simple sample, please refer to it to see if it helps you.

Time span selection =
VAR _DAYMAX =
    MAXX ( ALL ( 'Table' ), 'Table'[cycle time-days] )
VAR _DAYMIN =
    MINX ( ALL ( 'Table' ), 'Table'[cycle time-days] )
VAR _DAYAVERAGE =
    AVERAGEX ( ALL ( 'Table' ), 'Table'[cycle time-days] )
VAR _WEEKMAX =
    MAXX ( ALL ( 'Table' ), 'Table'[sysle time- weeks] )
VAR _WEEKMIN =
    MINX ( ALL ( 'Table' ), 'Table'[sysle time- weeks] )
VAR _WEEKAVERAGE =
    AVERAGEX ( ALL ( 'Table' ), 'Table'[sysle time- weeks] )
VAR _MONTHMAX =
    MAXX ( ALL ( 'Table' ), 'Table'[cycle time- months] )
VAR _MONTHMIN =
    MINX ( ALL ( 'Table' ), 'Table'[cycle time- months] )
VAR _MONTHAVERAGE =
    AVERAGEX ( ALL ( 'Table' ), 'Table'[cycle time- months] )
RETURN
    SWITCH (
        TRUE (),
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Day",
            VALUES ( 'Measure selector'[Measure selector] ) = "Avg"
        ), _DAYAVERAGE,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Week",
            VALUES ( 'Measure selector'[Measure selector] ) = "Avg"
        ), _WEEKAVERAGE,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Month",
            VALUES ( 'Measure selector'[Measure selector] ) = "Avg"
        ), _MONTHAVERAGE,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Day",
            VALUES ( 'Measure selector'[Measure selector] ) = "Min"
        ), _DAYMIN,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Week",
            VALUES ( 'Measure selector'[Measure selector] ) = "Min"
        ), _WEEKMIN,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Month",
            VALUES ( 'Measure selector'[Measure selector] ) = "Min"
        ), _MONTHMIN,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Day",
            VALUES ( 'Measure selector'[Measure selector] ) = "Max"
        ), _DAYMAX,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Week",
            VALUES ( 'Measure selector'[Measure selector] ) = "Max"
        ), _WEEKMAX,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Month",
            VALUES ( 'Measure selector'[Measure selector] ) = "Max"
        ), _MONTHMAX,
        BLANK ()
    )

vpollymsft_0-1666763453457.png

 

 

If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @tvadoc ,

I have created a simple sample, please refer to it to see if it helps you.

Time span selection =
VAR _DAYMAX =
    MAXX ( ALL ( 'Table' ), 'Table'[cycle time-days] )
VAR _DAYMIN =
    MINX ( ALL ( 'Table' ), 'Table'[cycle time-days] )
VAR _DAYAVERAGE =
    AVERAGEX ( ALL ( 'Table' ), 'Table'[cycle time-days] )
VAR _WEEKMAX =
    MAXX ( ALL ( 'Table' ), 'Table'[sysle time- weeks] )
VAR _WEEKMIN =
    MINX ( ALL ( 'Table' ), 'Table'[sysle time- weeks] )
VAR _WEEKAVERAGE =
    AVERAGEX ( ALL ( 'Table' ), 'Table'[sysle time- weeks] )
VAR _MONTHMAX =
    MAXX ( ALL ( 'Table' ), 'Table'[cycle time- months] )
VAR _MONTHMIN =
    MINX ( ALL ( 'Table' ), 'Table'[cycle time- months] )
VAR _MONTHAVERAGE =
    AVERAGEX ( ALL ( 'Table' ), 'Table'[cycle time- months] )
RETURN
    SWITCH (
        TRUE (),
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Day",
            VALUES ( 'Measure selector'[Measure selector] ) = "Avg"
        ), _DAYAVERAGE,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Week",
            VALUES ( 'Measure selector'[Measure selector] ) = "Avg"
        ), _WEEKAVERAGE,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Month",
            VALUES ( 'Measure selector'[Measure selector] ) = "Avg"
        ), _MONTHAVERAGE,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Day",
            VALUES ( 'Measure selector'[Measure selector] ) = "Min"
        ), _DAYMIN,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Week",
            VALUES ( 'Measure selector'[Measure selector] ) = "Min"
        ), _WEEKMIN,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Month",
            VALUES ( 'Measure selector'[Measure selector] ) = "Min"
        ), _MONTHMIN,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Day",
            VALUES ( 'Measure selector'[Measure selector] ) = "Max"
        ), _DAYMAX,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Week",
            VALUES ( 'Measure selector'[Measure selector] ) = "Max"
        ), _WEEKMAX,
        AND (
            VALUES ( 'Time span selector'[Time span selector] ) = "Month",
            VALUES ( 'Measure selector'[Measure selector] ) = "Max"
        ), _MONTHMAX,
        BLANK ()
    )

vpollymsft_0-1666763453457.png

 

 

If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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