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
Nathan__Mox
Helper I
Helper I

Power BI Desktop creating a separate DAX calculation for certain rows

Hi all, 

 

I have a dax calculatioin of 

Column = [on Hand] + sumx(filter('graph test', 'graph test'[date] <= earlier('graph test'[date]) && [Item code] = earlier([item code]) ), [Qty] - [Weekly max Sales] ) , which calculates current/forecast stock level. Ive now realised that The current week is included in this calculation but the on hand value has already been calculated for the current week, so the current week should just equal on hand. If someone can help me exclude the 1st row of each different Category from the above DAX calculation and make it just equal on hand I would be very thankful.
 
If any more context or tables are needed let me know.
 
Thanks
1 ACCEPTED SOLUTION

@Nathan__Mox 

pls try this

Column = if('Table'[Date (Week starting).]=CALCULATE(min('Table'[Date (Week starting).]),ALLEXCEPT('Table','Table'[Item Code.])),'Table'[on hand], 99999)

replace 99999 with your current formula.

1.PNG





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

Proud to be a Super User!




View solution in original post

7 REPLIES 7
ryan_mayu
Super User
Super User

@Nathan__Mox 

could you pls provide the sample data and expected output?





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

Proud to be a Super User!




Below is my data (sorry for the mess had to cover sensitive infomation), week 28 (3rd row from bottom) is the current week. Since the on hand column has already subtracted the sales and added the inbound items for the current week I dont want it done twice as seen below (I know on hand is 455 and the inbound items is 2500 for current week thats just mock data as at the moment im waiting for Inbound items data). Instead I want the current week to equal on hand without messing up current calculation. On top of that the current week row needs to be automated so that next week, week 29 will be current week and will equal on hand value.

If you could please help me out Ill be very grateful.

If any other infomation is needed let me know

 

Thanks

2022-07-07 - Copy.png

@Nathan__Mox 

could you pls create some dummy data and provide the expected output?





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

Proud to be a Super User!




Current

Week number.Date (Week starting).Item Code.Qty (inbound Items).Weekly max sales.forecasted stock levelson hand
284th julya0251540
2911th julya50254040
3018th julya0251540
3125 julya20251040
284th julyb40355550
2911 julyb50357050
3018th julyb0353550
3125th julyb035050

 

What I want

Week number.Date (Week starting).Item Code.Qty (inbound Items).Weekly max sales.forecasted stock levelson hand
284th julya025

(<-- ignore) 40

           (= -->)

40
2911th julya50256540
3018th julya0254040
3125 julya20253540
284th julyb4035

(<-- ignore) 50

              (= -->)

50
2911 julyb50356550
3018th julyb0353050
3125th julyb035-550

 

Thanks

@Nathan__Mox 

pls try this

Column = if('Table'[Date (Week starting).]=CALCULATE(min('Table'[Date (Week starting).]),ALLEXCEPT('Table','Table'[Item Code.])),'Table'[on hand], 99999)

replace 99999 with your current formula.

1.PNG





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

Proud to be a Super User!




Thank you heaps.

instead of having the 99999 at the end of calculation I swapped it for this calc [on Hand] + sumx(filter('graph test''graph test'[date] <= earlier('graph test'[date]) && [Item code] = earlier([item code]) ), [Qty] - [Weekly max Sales] ) which worked perfectly.

 

Thank you !!

you are welcome





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

Proud to be a Super User!




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.