Forum Discussion

lucasvaranda's avatar
lucasvaranda
New Member
2 years ago
Solved

DAX

Hello everyone, I'm having a problem viewing my measurement on the card, which compares the current day to the previous day in percentages. I can see it normally on the graph and I can't see it on the card.

1: % preço = CALCULATE([Preço de venda](DATEADD(Calendario[Data].[Date], -1, DAY)))

2: var % preço = DIVIDE([Preço de venda] - [% preço], [% preço])
3: teste03 = FORMAT([var % preço]" ⬆ 0%; ⬇ 0%")



 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi lucasvaranda ,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    SalePriceDifference = 
    VAR _CurrentRowDate =
        MAX ( 'Table'[Date] )
    VAR _PreviousRowDate =
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < _CurrentRowDate )
        )
    RETURN
        IF (
            _PreviousRowDate <> BLANK (),
            SUM ( 'Table'[Sale price] )
                - CALCULATE (
                    SUM ( 'Table'[Sale price] ),
                    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = _PreviousRowDate )
                )
        )

    In Power BI Desktop, the card can only show one value, it doesn't show the values all together like a bar chart. It only show you the Total.

     

     

    Best Regards

    Yilong Zhou

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi lucasvaranda ,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    SalePriceDifference = 
    VAR _CurrentRowDate =
        MAX ( 'Table'[Date] )
    VAR _PreviousRowDate =
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < _CurrentRowDate )
        )
    RETURN
        IF (
            _PreviousRowDate <> BLANK (),
            SUM ( 'Table'[Sale price] )
                - CALCULATE (
                    SUM ( 'Table'[Sale price] ),
                    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = _PreviousRowDate )
                )
        )

    In Power BI Desktop, the card can only show one value, it doesn't show the values all together like a bar chart. It only show you the Total.

     

     

    Best Regards

    Yilong Zhou

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