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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
carlosmorales
Frequent Visitor

help getting the value of a calculated column

Hello everyone, thank you very much for your time and attention.

I need your help with the following, to be able to obtain the amount of the previous week from my data.

 

I got the amount of the current week, like this:

semana actual.jpg

and I thought that with the following calculated column, I would get the value of the previous week:

semana anterior.jpg

in order to calculate the variation between the current week and the previous week.

data

 

Thanks for the help.

 

 

 

 

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@carlosmorales solution attached, hope that is what you are looking for



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

MFelix
Super User
Super User

Hi @carlosmorales ,

 

Try the following code:

SemAnt =
CALCULATE (
    MAX ( 'CXC Detalle'[semactual] );
    FILTER (
        'CXC Detalle';
        'CXC Detalle'[semana]
            = EARLIER ( 'CXC Detalle'[semana] ) - 1
    );
    'CXC Detalle'[Cliente] = EARLIER ( 'CXC Detalle'[Cliente] );
    'CXC Detalle'[Rangos Vencimiento]
        = EARLIER ( 'CXC Detalle'[Rangos Vencimiento] )
)

PBIX file attach.

 

Although I must advise that looking at the data you have you should make measures and not calculated columns since this will add size to your model. Using calculated measure that will alow more flexebility in the use of the data:

Monto = SUM('CXC Detalle'[Monto USD])

Previous week Monto =
CALCULATE (
    SUM ( 'CXC Detalle'[Monto USD] );
    FILTER (
        ALL ( 'CXC Detalle'[semana] );
        'CXC Detalle'[semana]
            = MAX ( 'CXC Detalle'[semana] ) - 1
    )
)

Variation = [Monto] - [Previous week Monto]

Be aware that the previous week need to be adjust in case you have more than 1 year on your data but it's similar to what is written.

 

As you can see  on the file using measure the result is the same.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @carlosmorales ,

 

Try the following code:

SemAnt =
CALCULATE (
    MAX ( 'CXC Detalle'[semactual] );
    FILTER (
        'CXC Detalle';
        'CXC Detalle'[semana]
            = EARLIER ( 'CXC Detalle'[semana] ) - 1
    );
    'CXC Detalle'[Cliente] = EARLIER ( 'CXC Detalle'[Cliente] );
    'CXC Detalle'[Rangos Vencimiento]
        = EARLIER ( 'CXC Detalle'[Rangos Vencimiento] )
)

PBIX file attach.

 

Although I must advise that looking at the data you have you should make measures and not calculated columns since this will add size to your model. Using calculated measure that will alow more flexebility in the use of the data:

Monto = SUM('CXC Detalle'[Monto USD])

Previous week Monto =
CALCULATE (
    SUM ( 'CXC Detalle'[Monto USD] );
    FILTER (
        ALL ( 'CXC Detalle'[semana] );
        'CXC Detalle'[semana]
            = MAX ( 'CXC Detalle'[semana] ) - 1
    )
)

Variation = [Monto] - [Previous week Monto]

Be aware that the previous week need to be adjust in case you have more than 1 year on your data but it's similar to what is written.

 

As you can see  on the file using measure the result is the same.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi,

@parry2k  and @MFelix 

good morning!

please excuse me for not responding before.


Thank you very much for your help, the two solutions are excellent.

 

Thank you for your time and knowledge to solve my dilemma.

parry2k
Super User
Super User

@carlosmorales solution attached, hope that is what you are looking for



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
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.