用已声明表的相关列值替换颜色值

问题描述 投票:0回答:1

_嗨,我有以下 DAX 度量,我想用同一 _BarTable 中“@Colour”列的相关颜色替换 XXXX 部分。我不知道该怎么办?感谢您的帮助 ! 链接到 Pbix 文件

VAR _BarTable=
    ADDCOLUMNS(
        SUMMARIZE('Crypto Data', 'Crypto Data'[timestamp]),
        "@Colour", IF(
                    [Current Price] = _YMaxValue, "Green",
                    IF( [Current Price] = _YMinValue, "Red",
                    _LineColor)
                   ),
        "@Bars",    "<rect x='" & INT(150 * DIVIDE('Crypto Data'[timestamp] - _XMinDate, _XMaxDate - _XMinDate)) &
                    "' width='1' stroke='" & XXXX & "' stroke-width='1' y='" &
                    50 -  INT(50 * DIVIDE([Current Price] - _YMinValue, _YMaxValue - _YMinValue)) & "' height='" &
                    INT(50 * DIVIDE([Current Price] - _YMinValue, _YMaxValue - _YMinValue)) &
                    "'  style='fill:" & XXXX & "'/>"
    )
powerbi dax data-analysis powerbi-desktop measure
1个回答
0
投票

试试这个。

VAR _BarTable=
    ADDCOLUMNS(
        SUMMARIZE('Crypto Data', 'Crypto Data'[timestamp]),

        "@Colour", IF(
                    [Current Price] = _YMaxValue, "Green",
                    IF( [Current Price] = _YMinValue, "Red",
                    _LineColor)
                   ),
    
        "@Bars",   
         
         VAR x = IF(
                    [Current Price] = _YMaxValue, "Green",
                    IF( [Current Price] = _YMinValue, "Red",
                    _LineColor)
                   )
         RETURN
         "<rect x='" & INT(150 * DIVIDE('Crypto Data'[timestamp] - _XMinDate, _XMaxDate - _XMinDate)) &
                    "' width='1' stroke='" & x & "' stroke-width='1' y='" &
                    50 -  INT(50 * DIVIDE([Current Price] - _YMinValue, _YMaxValue - _YMinValue)) & "' height='" &
                    INT(50 * DIVIDE([Current Price] - _YMinValue, _YMaxValue - _YMinValue)) &
                    "'  style='fill:" & x & "'/>"
    )
© www.soinside.com 2019 - 2024. All rights reserved.