Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
antoniodneto
Regular Visitor

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!!!

1 ACCEPTED SOLUTION

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 selectedno date is selectedselected dateselected 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.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @antoniodneto 

 

I would create a new measure as

_KPI = CALCULATE(SUM('table1'[VALUE]),ALLEXCEPT('table1','table1'[date_sell]))

and use it to display the KPI values

 

 

Hi @antoniodneto ,

 

Try this measure

KPI =
IF (
    MAX ( 'Table'[date] )
        IN VALUES ( 'Table'[date_sell] ),
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date_sell]
                = MAX ( 'Table'[date_sell] )
        )
    ),
    0
)

 

 

1.jpg

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Hi, IT WORKED!!!

 

Just one thing, when I select month by month return me correct. But when not month is selected it shows me the value for max date_sell, in this case should accumulated. Can I add that?

 

Tks a lot!!!

Hi @antoniodneto ,

 

Not very clear , but it accumulates the value of the max_date sell.

 

I think this is what you want.

 

Let me know if this help. 

 

Also, pls accept as solution for other community members to benefit.

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

So, when I select month by month the expression works. When I dont select any month the value is the same if I select 2007 (my max date). I would like to accumulate all the values for DATE_SELL when I don`t select any month.

 

Sorry if my explanation is not clearly.

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 selectedno date is selectedselected dateselected 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.

Hi, Didn`t work.

 

Don`t matter wich month is selected, it returns the same value. Looks like when I select the month it accumulated all values for date_sell.

 

Tks!!

amitchandak
Super User
Super User

@antoniodneto , not very clear.  You can join both dates with the same date table. One join will active another will be inactive join. You can activate join using userelation 

 

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, sorry. I don`t understand your post. All the language is new for me.

Can I fix using a expression?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.