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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MKPartner
Helper I
Helper I

Substracting data for proper visualization

Hi All, 

 

I have data to calculate for next 4 weeks in one column. It's "lam_var" column. I'm trying to calculate value for each seprately but with simple SUM function I got only cumulative value for each week like below.

 

bi ex.png

 

Lam_Variance = ABS(SUM('Demand Schedule_Lam D'[lam_var]))

 

I'd like to see real value for each prod_family line and total for each week as well. I will have more data with next weeks but always for actual week and visibility for next 3 weeks.

 

Thanks for your support.

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

hi @MKPartner 

First get the number equivalent of your week (not wk42, 43) as you will have trouble comparing those weeks if week numbers aren't always in "00" format. For example Wk10 is next to Wk1 alphabetically. You should be able to get that in the query editor by duplicating your week colum and then replacing WK with nothing for the duplicate. Once you have that, create this measure:

VAR _prevWk =
    CALCULATE (
        [sum of value],
        FILTER (
            ALL ( 'table'[wk number] ),
            'table'[wk number]
                = MAX ( 'table'[wk number] ) - 1
        )
    )
RETURN
    [sum of value] - _prevWk

 

Otherwise please provide a workable sample data (not an image), your expected result from the same sample data and your reasoning behind. You may post a link to Excel or a sanitized copy of your PBIX stored in the cloud.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
grazitti_sapna
Super User
Super User

@MKPartner  try this

 

Lam_Variance_Weekly =
VAR CurrentWeek =
SELECTEDVALUE('Demand Schedule_Lam D'[Week])
RETURN
CALCULATE(
ABS(SUM('Demand Schedule_Lam D'[lam_var])),
'Demand Schedule_Lam D'[Week] = CurrentWeek
)

danextian
Super User
Super User

hi @MKPartner 

First get the number equivalent of your week (not wk42, 43) as you will have trouble comparing those weeks if week numbers aren't always in "00" format. For example Wk10 is next to Wk1 alphabetically. You should be able to get that in the query editor by duplicating your week colum and then replacing WK with nothing for the duplicate. Once you have that, create this measure:

VAR _prevWk =
    CALCULATE (
        [sum of value],
        FILTER (
            ALL ( 'table'[wk number] ),
            'table'[wk number]
                = MAX ( 'table'[wk number] ) - 1
        )
    )
RETURN
    [sum of value] - _prevWk

 

Otherwise please provide a workable sample data (not an image), your expected result from the same sample data and your reasoning behind. You may post a link to Excel or a sanitized copy of your PBIX stored in the cloud.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Shubham_rai955
Impactful Individual
Impactful Individual

To show real weekly values instead of cumulative, calculate the difference between each week's value and the previous week:
WeeklyValue = CurrentWeekValue - PreviousWeekValue


Apply this for each prod_family and week; for the first week, use the value as-is. This way, your table shows only the actual value added that week.

Thank you. I know how to it should work in theory but I have a problem to implment this with DAX code. There is screenshot from my data model if that helps. Data are for week 42 to 45 actualy. I'll polute data on daily basis so on Monday I would have data for weeks 43-46: 

 

bi ex.png

grazitti_sapna
Super User
Super User

Hi @MKPartner,

 

Use Below DAX

 

Lam_Variance_Weekly =
SUMX(
VALUES('Demand Schedule_Lam D'[Week]), -- or your week/date column
ABS(SUM('Demand Schedule_Lam D'[lam_var]))
)

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

Thanks for feedback but it's not the result which I want to have. Values for each week didn't change. Only last column is different againt previous image.

 

bi ex.png

Helpful resources

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors