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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
clarainesgg
Helper I
Helper I

Sum of Unitis before 4 moths giving % according the brand

Hi, Hope you are doing well.

 

I am facing a calculation. I got the sum of units of previous of my 4 months from today. However, it is not doing ok the calculation if I give a % to a certain brand. If I apply the same weight, it works fine. 

 

Do you know what it is wrong?

 

Previous_4_Months_Units =
VAR LastDateYTD =
ENDOFYEAR('In & Out'[Date])

VAR StartDate4MonthsBack =
EDATE(LastDateYTD, -4)

RETURN
CALCULATE([Units_Sell-In],
'In & Out'[Date] <= StartDate4MonthsBack
)
 
This formula is bring ok.
 
Then, I need to apply:
 
2ndUnits= if [Name]= "A" then [Previous_4_Months_Units]*0,7
elseif [Name]= "b" then [Previous_4_Months_Units]*0,6
elseif [Name]= "c" then [Previous_4_Months_Units]*0,5
 
end [Previous_4_Months_Units]*0,4
 
 
I tried this formula: 
 
test =
SUMX('In & Out',
    SWITCH(
        TRUE(),
        'In & Out'[Nombre] = "Va",[Previous_4_Months_Units]*0.7,
       'In & Out'[Nombre] = "Ce" || 'In & Out'[Nombre] = "Stamboulian", [Previous_4_Months_Units]*  0.6,
        [Previous_4_Months_Units]*  0.5
    )
)
 
 

 

 

Thanks for your help!

 

Clara

 

 

7 REPLIES 7
clarainesgg
Helper I
Helper I

Ok, I just shared with you via LinkeIn. Thanks!

Anonymous
Not applicable

Hi @clarainesgg ,

 

First of all thanks to Ritaf1983  for the quick reply. I have some other thoughts to add:

You can create this measure.

test = SWITCH(TRUE(),
MAX('Sell-In'[Nombre])="VA",[Previous_4_Months_Units]*0.7,
MAX('Sell-In'[Nombre])="CEI",[Previous_4_Months_Units]*0.6,
MAX('Sell-In'[Nombre])="PRE",[Previous_4_Months_Units]*0.6,
[Previous_4_Months_Units]*0.4)
test2 = SUMX(VALUES('Sell-In'[Nombre]),[test]) 

Then the result is as follows.

vtangjiemsft_0-1725864905697.png

 

Best Regards,

Neeko Tang

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

Thanks! It works 🙂

Ritaf1983
Super User
Super User

Hi @clarainesgg 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi, Below you could find my template. If you can see, the number is not correct. (I dont know how to attach)

 

clarainesgg_2-1725658642945.png

 

 

 

clarainesgg_1-1725658596835.png

 

 

 

clarainesgg_0-1725658363658.png

 

thanks!

Hi @clarainesgg 
You can save the file of some kind of public cloud and share it via link.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

If I applied this:

2ndoses_va = [Previous_4_Months_Units]*0.7 works. However, I need to apply conditions according to Name.
 
Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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