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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andreaturri27
Helper I
Helper I

Increase Order and Price

Good Morning,

 

sorry for my english. 

 

How calculate increase / Decrease item and  % increse  in this table?

Immagine.png

 

Thank you 

 

2 ACCEPTED SOLUTIONS
v-janeyg-msft
Community Support
Community Support

Hi, @andreaturri27 

 

According to your description, you can create two measures.

Like this:

Measure1 = 
VAR a =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            [ExpectedDeliveryDate] < SELECTEDVALUE ( 'Table'[ExpectedDeliveryDate] )
        ),
        [ExpectedDeliveryDate]
    )
VAR b =
    MAXX (
        FILTER ( ALL ( 'Table' ), [ExpectedDeliveryDate] = a ),
        [Prezzo acquisto]
    )
RETURN
    MAX( 'Table'[Prezzo acquisto] ) - b
Measure2 = 
VAR a =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            [ExpectedDeliveryDate] < SELECTEDVALUE ( 'Table'[ExpectedDeliveryDate] )
        ),
        [ExpectedDeliveryDate]
    )
VAR b =
    MAXX (
        FILTER ( ALL ( 'Table' ), [ExpectedDeliveryDate] = a ),
        [Prezzo acquisto]
    )
RETURN
    DIVIDE (
        MAX ( 'Table'[Prezzo acquisto] ) - b,
        MAX ( 'Table'[Prezzo acquisto] )
    )

vjaneygmsft_0-1635240012825.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

View solution in original post

Hi, @andreaturri27 

 

You need to modify the code according to your needs.

Like :

Measure1 = 
VAR a =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            [ExpectedDeliveryDate] < SELECTEDVALUE ( 'Table'[ExpectedDeliveryDate] )&&
            [item] < SELECTEDVALUE ( 'Table'[item] )
        ),
        [ExpectedDeliveryDate]
    )
VAR b =
    MAXX (
        FILTER ( ALL ( 'Table' ), [ExpectedDeliveryDate] = a && 
        [item] < SELECTEDVALUE ( 'Table'[item] )),
        [Prezzo acquisto]
    )
RETURN
    MAX( 'Table'[Prezzo acquisto] ) - b

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

 

View solution in original post

4 REPLIES 4
andreaturri27
Helper I
Helper I

Thaks for reply @v-janeyg-msft  but in my table have a lot value in this table.

i must verify item and ExpectedDeliveryDate...

desk2.png

how do to solve?

Thank you

 

Andrea

 

Hi, @andreaturri27 

 

You need to modify the code according to your needs.

Like :

Measure1 = 
VAR a =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            [ExpectedDeliveryDate] < SELECTEDVALUE ( 'Table'[ExpectedDeliveryDate] )&&
            [item] < SELECTEDVALUE ( 'Table'[item] )
        ),
        [ExpectedDeliveryDate]
    )
VAR b =
    MAXX (
        FILTER ( ALL ( 'Table' ), [ExpectedDeliveryDate] = a && 
        [item] < SELECTEDVALUE ( 'Table'[item] )),
        [Prezzo acquisto]
    )
RETURN
    MAX( 'Table'[Prezzo acquisto] ) - b

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

 

v-janeyg-msft
Community Support
Community Support

Hi, @andreaturri27 

 

According to your description, you can create two measures.

Like this:

Measure1 = 
VAR a =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            [ExpectedDeliveryDate] < SELECTEDVALUE ( 'Table'[ExpectedDeliveryDate] )
        ),
        [ExpectedDeliveryDate]
    )
VAR b =
    MAXX (
        FILTER ( ALL ( 'Table' ), [ExpectedDeliveryDate] = a ),
        [Prezzo acquisto]
    )
RETURN
    MAX( 'Table'[Prezzo acquisto] ) - b
Measure2 = 
VAR a =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            [ExpectedDeliveryDate] < SELECTEDVALUE ( 'Table'[ExpectedDeliveryDate] )
        ),
        [ExpectedDeliveryDate]
    )
VAR b =
    MAXX (
        FILTER ( ALL ( 'Table' ), [ExpectedDeliveryDate] = a ),
        [Prezzo acquisto]
    )
RETURN
    DIVIDE (
        MAX ( 'Table'[Prezzo acquisto] ) - b,
        MAX ( 'Table'[Prezzo acquisto] )
    )

vjaneygmsft_0-1635240012825.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

goncalogeraldes
Super User
Super User

Hello there @andreaturri27 ! You can try the following for the variation:

Variation =
VAR _current =
    SUM ( Table[Prezzo acquisto] )
VAR _previous =
    CALCULATE (
        _current,
        FILTER (
            ALL ( Table[Numero Ordine] ),
            Table[Numero Ordine]
                = ( SELECTEDVALUE ( Table[Numero Ordine] ) - 1 )
        )
    )
RETURN
    _current - _previous

 And for the percentage change:

 

% Variation =
VAR _current =
    SUM ( Table[Prezzo acquisto] )
VAR _previous =
    CALCULATE (
        _current,
        FILTER (
            ALL ( Table[Numero Ordine] ),
            Table[Numero Ordine]
                = ( SELECTEDVALUE ( Table[Numero Ordine] ) - 1 )
        )
    )
RETURN
    DIVIDE ( _current - _previous, _previous, 0 )

And format it as a % field.

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.