Forum Discussion

antoniodneto's avatar
antoniodneto
Regular Visitor
6 years ago
Solved

Help with Expression

Hi guys,

I`m new with Power BI, can you help me?

 

I have one master filter on my dash called DATE, with 2001,2002..... 2007. is my contract date.

And another called DATE_SELL with 2001,2002.... 2007, is my contract date bill (when my customer really paid me).

 

On my KPI I want to display my sell value using my DATE_SELL, for example if I choose 2007 on my DATE filter, the KPI should return me on values on 2007 DATE_SELL.

Follow an example:

datedate_sellvalue

2001

2002500
20022002300
20032003100
20042005110
20052005200
20062007300
20072007600

 

In my case when I select 2007 on DATE it must return me all values into 2007 on DATE_SELL, 300+600.

But when I select 2007 my KPI only return me 600. How can I fix it?

 

Tks guys!!!

  • v-yingjl's avatar
    v-yingjl
    6 years ago

    Hi antoniodneto ,

    You can create this measure:

    Measure =
    VAR _max =
        CALCULATE ( MAX ( 'Table'[date] ), ALLSELECTED ( 'Table'[date] ) )
    RETURN
        IF (
            ISFILTERED ( 'Table'[date] ),
            IF (
                _max IN DISTINCT ( 'Table'[date_sell] ),
                CALCULATE (
                    SUM ( 'Table'[value] ),
                    FILTER ( ALL ( 'Table' ), 'Table'[date_sell] = MAX ( 'Table'[date_sell] ) )
                )
            ),
            SUM ( 'Table'[value] )
        )

    no date is selectedselected date

     

    Attached a sample file that hopes to help you: Help with Expression.pbix

     

    Best Regards,
    Yingjie Li

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

9 Replies