Forum Discussion

admiralman's avatar
admiralman
Advocate II
8 years ago

Measure and Data Type

i have a measure that uses the selected value of a slicer to determine which calculation (data point) it will return. See below.

 

The issue is that I want A% to return a number to the 100ths decimal while the others I want to only return the data to the whole number. I can do this with Format() functionality but when I do I cannot use the measure in a chart. I tried to wrap Format within a Value call and it error'd out. Any idea how to accomplish this without doing one measure for charts and one for grids?

 

 

DPs =
var yr = Year(NOW())
return
SWITCH(SELECTEDVALUE(MeasureDDL[Measure]),
"A, CALCULATE([MeasureA], Data[yr]=yr),
"B", CALCULATE([MeasureA], Data[yr]=yr),
"A%", CALCULATE([MeasureAPercent], Data[yr]=yr)),
0)

1 Reply

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    Hi admiralman,

     

    Modify your measure like pattern below and check if it can meet your requirement.

     

    DPs =
    VAR yr =
        YEAR ( NOW () )
    RETURN
        SWITCH (
            SELECTEDVALUE ( MeasureDDL[Measure] ),
            "A", CALCULATE ( [MeasureA], Data[yr] = yr ),
            "B", CALCULATE ( [MeasureA], Data[yr] = yr ),
            "A%", CALCULATE ( [MeasureAPercent], Data[yr] = yr )
                * 100
                && "%",
            0
        )
    

    Regards,

    Jimmy Tao