Forum Discussion

Buttersworth's avatar
Buttersworth
New Member
3 years ago

Help combining multiple switch measures (Fully dynamic visual)

I have a series of measures that are controlled by several switch tables and slicers that feed into each other to create a dynamic one visual report that allows the selection of any dimension in cumulative or total count/cost displayed by month, quarter, week, or year, but I need help simplifying/restructuring into a single measure. I tried combining the measures into one and using VAR for the inputs, but I can't wrap my head around how to feed from one measure to the next in a combined fashion.

----Basic Measures----

 

Project Count = COUNT('Fact Weekly Pipeline Update'[Project ID])
 
--
 
Intake Cost = Sum('Fact Weekly Pipeline Update'[Cost])

-----Switching between Count and Cost-----

Count/Cost =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Switch Table Basic'[Label] ) = "Count"CALCULATE ( [Project Count] ),
    SELECTEDVALUE ( 'Switch Table Basic'[Label] ) = "Cost"CALCULATE ( [Intake Cost] ),
    CALCULATE ( [Project Count] )
)

--Switch Table Basic--

 

-----Cumulative Totals of Basic Measures Selected in the previous measure-----

Cumulative Count/Cost =
CALCULATE (
    'Basic Measure Slicer'[Count/Cost],
    FILTER (
        ALLSELECTED ( 'Calendar'[Date] ),
        'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    )
)
 
--Calendar--

  

----Switching between Cumulative or Non-Cumulative totals of Basic Measures-----
 
Current/Cumulative Count/Cost Switch =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Switch Table Cumulative/Current'[Category] ) = "Non-Cumulative", CALCULATE ( [Count/Cost] ),
    SELECTEDVALUE ( 'Switch Table Cumulative/Current'[Category] ) = "Cumulative", CALCULATE ( [Cumulative Count/Cost] ),
    CALCULATE ( [Count/Cost] )
)
 
--Switch Table Cumulative/Current--

 

-----Displaying the result of the previous measures by Selected Dimensions-----
 
DIM Slicer Current/Cumulative Switch Count/Cost =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Analytics / Infrastructure",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM Analytics Infrastructure'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Codes",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM Codes'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "FP/MP",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM FP/MP'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Funding Model",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM Funding Model'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Project Status",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM New Status'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Project Sub-Status",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM New Sub Status'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Funded/Unfunded",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM Funding'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Project Characteristics",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'Prep Project Characteristics Ind'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Project Condition",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'Prep Project Conditions Ind'[DIM] )
        ),
    SELECTEDVALUE ( 'Switch Table DIM Slicer'[Category] ) = "Project Condition/Characteristic",
        CALCULATE (
            [Current/Cumulative Count/Cost Switch],
            USERELATIONSHIP ( 'Switch Table DIM Slicer'[Labels], 'DIM Project Condition/Characteristics'[DIM] )
        )
)
 
--Switch Table DIM Slicer--

 

--DIM Funding Model-- (As example, there are several tables set up like this that are reference in the measure above)

 



-----Changing the time series to Year, Quarter, Month, Week-----
 
Date and DIM Slicer Current/Cumulative Switch Count/Cost =
SWITCH (
    SELECTEDVALUE ( 'Date Slicer'[Index Dexc], 1 ),
    1,
        CALCULATE (
            [DIM Slicer Current/Cumulative Switch Count/Cost],
            TREATAS ( VALUES ( 'Date Slicer'[Period] ), 'Calendar'[Year] )
        ),
    2,
        CALCULATE (
            [DIM Slicer Current/Cumulative Switch Count/Cost],
            TREATAS ( VALUES ( 'Date Slicer'[Period] ), 'Calendar'[Q & Y] )
        ),
    3,
        CALCULATE (
            [DIM Slicer Current/Cumulative Switch Count/Cost],
            TREATAS ( VALUES ( 'Date Slicer'[Period] ), 'Calendar'[M & Y] )
        ),
    4,
        CALCULATE (
            [DIM Slicer Current/Cumulative Switch Count/Cost],
            TREATAS ( VALUES ( 'Date Slicer'[Period] ), 'Calendar'[End of Week] )
        ),
    CALCULATE (
        [DIM Slicer Current/Cumulative Switch Count/Cost],
        TREATAS ( VALUES ( 'Date Slicer'[Period] ), 'Calendar'[Year] )
    )
)

--Date Slicer(Contains --

 

 

----Data Model----

 





 

2 Replies

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Buttersworth 

     

    Based on the data you provided, can you give one or two examples of what your expected output looks like?

     

    Best Regards,

    Community Support Team _Charlotte

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

  • Hi v-zhangti ,

    Thanks for responding!

    The measures work fine in visuals already. The "Date and DIM Slicer Current/Cumulative Switch Count/Cost" and "Period" from "Date Slicer" allow the user to fully control the visual with the filters below:

     

    The main chart below, is fully controlled:

     

    I really just need help with combining all of these measures into one to simplify and optimize the report. The only issue I have that I am trying to work out seperately, is displaying dates with no data within the selected range. I have been toying with the basic measures (Project Count and Project Cost) to fix this issue, but I think the issue may be coming from another measure higher up in the chain. Either way, getting the measures into one is the main goal and I think that would help me fix the secondary issue of displaying dates with no data.

     

    Thank you so much!