Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello Guys.
Im trying to create some dashboard with SAP information (MBEWH and MARDH tables).
Those tables have the Stock Position for all materials in each month-end.
The problem with that is if the material stock position has not changed from one month to another, the information is not populated on the tables. There is a small sample of the table below (Sample 1).
I need to Populate the missing Months with the last stock position.
Steps that i did so far:
1. Created a Calendar Table: Z1_Month_Year = SUMMARIZE(ADDCOLUMNS(CALENDAR(Date("2000","01","01"), Today()), "Month", Month([Date]),"Year", YEAR([Date]), "Z_Year_Month", Year([Date])&"_"&MONTH([Date])), [Z_Year_Month], [Year],[Month])
2. Summarized Material Table: Z1_Material_Data = SUMMARIZE(SAP_MARDH,SAP_MARDH[MANDT_Client], SAP_MARDH[WERKS_Plant], SAP_MARDH[MATNR_Material])
3. CrossJoin Both Tables: Z1_Cross-Date_Mat = CROSSJOIN(Z1_Material_Data, Z1_Month_Year)
Until now i couldnt find a Function to Populate Missing values. The closest function i have (below - Function 1), is not considering that in those tables i have several Materials, Divisions, and Clients.
Thanks!
Sample 1:
Client | Material | Plant | Year | Month | Stock Position |
101 | 1420108 | DO50 | 2015 | 7 | 8.806,00 |
101 | 1420108 | DO50 | 2015 | 8 | 8.807,00 |
101 | 1420108 | DO50 | 2015 | 10 | 938,00 |
101 | 1420108 | DO50 | 2015 | 11 | 941,00 |
101 | 1420108 | DO50 | 2015 | 12 | 945,00 |
101 | 1420108 | DO50 | 2016 | 12 | 943,00 |
101 | 1420108 | DO50 | 2017 | 4 | 943,00 |
101 | 1420108 | DO50 | 2017 | 5 | 746,00 |
101 | 1420108 | DO50 | 2017 | 6 | - |
101 | 1420108 | DO50 | 2017 | 12 | - |
Function1:
Z_StockPosition = VAR LastNonBlankDate = CALCULATE ( LASTNONBLANK ( 'Z1_Cross-Date_Mat'[Z_EndOfMOnth], 1 ), FILTER ( ALL ( 'Z1_Cross-Date_Mat'), 'Z1_Cross-Date_Mat'[Z_EndOfMOnth] <= EARLIER ( 'Z1_Cross-Date_Mat'[Z_EndOfMOnth] ) && NOT ( ISBLANK ( 'Z1_Cross-Date_Mat'[Z_StockPositionHL] ) ) )) RETURN CALCULATE ( MAX ( 'Z1_Cross-Date_Mat'[Z_StockPositionHL] ), FILTER ( ALL ( 'Z1_Cross-Date_Mat' ), 'Z1_Cross-Date_Mat'[Z_EndOfMOnth] = LastNonBlankDate ) )
This is how the full table looks like:
Client | Material | Plant | Year | Month | Stock Position |
101 | 1420108 | DO50 | 2012 | 6 | 0 |
101 | 1420108 | DO50 | 2012 | 7 | 0 |
101 | 1420108 | DO50 | 2012 | 8 | 1.766,00 |
101 | 1420108 | DO50 | 2012 | 9 | 1.884,00 |
101 | 1420108 | DO50 | 2012 | 11 | 0 |
101 | 1420108 | DO50 | 2012 | 12 | 163 |
101 | 1420108 | DO50 | 2013 | 7 | 0 |
101 | 1420108 | DO50 | 2013 | 8 | 2.016,00 |
101 | 1420108 | DO50 | 2013 | 9 | 2.173,00 |
101 | 1420108 | DO50 | 2013 | 10 | 4.997,00 |
101 | 1420108 | DO50 | 2013 | 11 | 5.591,00 |
101 | 1420108 | DO50 | 2013 | 12 | 5.998,00 |
101 | 1420108 | DO50 | 2014 | 1 | 6.138,00 |
101 | 1420108 | DO50 | 2014 | 2 | 6.216,00 |
101 | 1420108 | DO50 | 2014 | 3 | 6.503,00 |
101 | 1420108 | DO50 | 2014 | 4 | 2.259,00 |
101 | 1420108 | DO50 | 2014 | 5 | 3.432,00 |
101 | 1420108 | DO50 | 2014 | 6 | 8.591,00 |
101 | 1420108 | DO50 | 2014 | 7 | 8.619,00 |
101 | 1420108 | DO50 | 2014 | 8 | 8.656,00 |
101 | 1420108 | DO50 | 2014 | 9 | 8.745,00 |
101 | 1420108 | DO50 | 2014 | 10 | 8.755,00 |
101 | 1420108 | DO50 | 2014 | 11 | 8.765,00 |
101 | 1420108 | DO50 | 2014 | 12 | 8.763,00 |
101 | 1420108 | DO50 | 2015 | 1 | 8.765,00 |
101 | 1420108 | DO50 | 2015 | 2 | 8.792,00 |
101 | 1420108 | DO50 | 2015 | 4 | 8.797,00 |
101 | 1420108 | DO50 | 2015 | 5 | 8.799,00 |
101 | 1420108 | DO50 | 2015 | 6 | 8.803,00 |
101 | 1420108 | DO50 | 2015 | 7 | 8.806,00 |
101 | 1420108 | DO50 | 2015 | 8 | 8.807,00 |
101 | 1420108 | DO50 | 2015 | 10 | 938 |
101 | 1420108 | DO50 | 2015 | 11 | 941 |
101 | 1420108 | DO50 | 2015 | 12 | 945 |
101 | 1420108 | DO50 | 2016 | 12 | 943 |
101 | 1420108 | DO50 | 2017 | 4 | 943 |
101 | 1420108 | DO50 | 2017 | 5 | 746 |
101 | 1420108 | DO50 | 2017 | 6 | 0 |
101 | 1420108 | DO50 | 2017 | 12 | 0 |
101 | 1420108 | DO50 | 2018 | 4 | 0 |
101 | 1420109 | DO50 | 2012 | 6 | 0 |
101 | 1420109 | DO50 | 2012 | 7 | 0 |
101 | 1420109 | DO50 | 2012 | 11 | 0 |
101 | 1420109 | DO50 | 2012 | 12 | 8.325,00 |
101 | 1420109 | DO50 | 2013 | 8 | 0 |
101 | 1420109 | DO50 | 2013 | 9 | 0 |
101 | 1420109 | DO50 | 2013 | 10 | 66 |
101 | 1420109 | DO50 | 2013 | 11 | 66 |
101 | 1420109 | DO50 | 2013 | 12 | 0 |
101 | 1420109 | DO50 | 2014 | 1 | 0 |
101 | 1420109 | DO50 | 2014 | 2 | 198 |
101 | 1420109 | DO50 | 2014 | 3 | 396 |
101 | 1420109 | DO50 | 2014 | 4 | 660 |
101 | 1420109 | DO50 | 2014 | 5 | 264 |
101 | 1420109 | DO50 | 2014 | 6 | 330 |
101 | 1420109 | DO50 | 2014 | 7 | 858 |
101 | 1420109 | DO50 | 2014 | 8 | 944 |
101 | 1420109 | DO50 | 2014 | 9 | 990 |
101 | 1420109 | DO50 | 2014 | 10 | 990 |
101 | 1420109 | DO50 | 2014 | 11 | 1.452,00 |
101 | 1420109 | DO50 | 2014 | 12 | 8.052,00 |
101 | 1420109 | DO50 | 2015 | 1 | 594 |
101 | 1420109 | DO50 | 2015 | 2 | 6.666,00 |
101 | 1420109 | DO50 | 2015 | 3 | 8.118,00 |
101 | 1420109 | DO50 | 2015 | 4 | 6.402,00 |
101 | 1420109 | DO50 | 2015 | 5 | 858 |
101 | 1420109 | DO50 | 2015 | 6 | 5.544,00 |
101 | 1420109 | DO50 | 2015 | 7 | 13.332,00 |
101 | 1420109 | DO50 | 2015 | 8 | 21.583,00 |
101 | 1420109 | DO50 | 2015 | 9 | 3.147,00 |
101 | 1420109 | DO50 | 2015 | 10 | 4.021,00 |
101 | 1420109 | DO50 | 2015 | 11 | 5.671,00 |
101 | 1420109 | DO50 | 2015 | 12 | 4.886,00 |
101 | 1420109 | DO50 | 2016 | 1 | 5.757,00 |
101 | 1420109 | DO50 | 2016 | 2 | 0 |
101 | 1420109 | DO50 | 2016 | 3 | 0 |
101 | 1420109 | DO50 | 2016 | 4 | 0 |
101 | 1420109 | DO50 | 2016 | 5 | 0 |
101 | 1420109 | DO50 | 2016 | 6 | 0 |
101 | 1420109 | DO50 | 2016 | 7 | 0 |
101 | 1420109 | DO50 | 2016 | 8 | 0 |
101 | 1420109 | DO50 | 2016 | 9 | 0 |
101 | 1420109 | DO50 | 2016 | 10 | 0 |
101 | 1420109 | DO50 | 2016 | 11 | 0 |
101 | 1420109 | DO50 | 2016 | 12 | 0 |
101 | 1420109 | DO50 | 2017 | 1 | 0 |
101 | 1420109 | DO50 | 2017 | 2 | 0 |
101 | 1420109 | DO50 | 2017 | 3 | 0 |
101 | 1420109 | DO50 | 2017 | 4 | 0 |
101 | 1420109 | DO50 | 2017 | 5 | 0 |
101 | 1420109 | DO50 | 2017 | 6 | 0 |
101 | 1420109 | DO50 | 2017 | 7 | 0 |
101 | 1420109 | DO50 | 2017 | 8 | 0 |
101 | 1420109 | DO50 | 2017 | 10 | 0 |
101 | 1420109 | DO50 | 2017 | 12 | 0 |
101 | 1420109 | DO50 | 2018 | 1 | 0 |
101 | 1420110 | DO50 | 2012 | 6 | 0 |
101 | 1420110 | DO50 | 2012 | 11 | 0 |
101 | 1420110 | DO50 | 2012 | 12 | 213 |
101 | 1420110 | DO50 | 2013 | 12 | 0 |
101 | 1420110 | DO50 | 2014 | 1 | 0 |
101 | 1420110 | DO50 | 2014 | 2 | 0 |
101 | 1420110 | DO50 | 2014 | 3 | 0 |
101 | 1420110 | DO50 | 2014 | 4 | 66 |
101 | 1420110 | DO50 | 2014 | 5 | 0 |
101 | 1420110 | DO50 | 2014 | 6 | 132 |
101 | 1420110 | DO50 | 2014 | 7 | 0 |
101 | 1420110 | DO50 | 2014 | 8 | 132 |
101 | 1420110 | DO50 | 2014 | 9 | 0 |
101 | 1420110 | DO50 | 2014 | 10 | 0 |
101 | 1420110 | DO50 | 2014 | 11 | 66 |
101 | 1420110 | DO50 | 2014 | 12 | 157 |
101 | 1420110 | DO50 | 2015 | 1 | 69 |
101 | 1420110 | DO50 | 2015 | 2 | 333 |
101 | 1420110 | DO50 | 2015 | 3 | 198 |
101 | 1420110 | DO50 | 2015 | 4 | 1.452,00 |
101 | 1420110 | DO50 | 2015 | 5 | 462 |
101 | 1420110 | DO50 | 2015 | 6 | 66 |
101 | 1420110 | DO50 | 2015 | 7 | 0 |
101 | 1420110 | DO50 | 2015 | 8 | 0 |
101 | 1420110 | DO50 | 2015 | 9 | 66 |
101 | 1420110 | DO50 | 2015 | 10 | 594 |
101 | 1420110 | DO50 | 2015 | 11 | 990 |
101 | 1420110 | DO50 | 2015 | 12 | 1.518,00 |
101 | 1420110 | DO50 | 2016 | 1 | 1.965,00 |
101 | 1420110 | DO50 | 2016 | 2 | 372 |
101 | 1420110 | DO50 | 2016 | 3 | 394 |
101 | 1420110 | DO50 | 2016 | 4 | 739 |
101 | 1420110 | DO50 | 2016 | 5 | 560 |
101 | 1420110 | DO50 | 2016 | 6 | 1.302,00 |
101 | 1420110 | DO50 | 2016 | 7 | 1.848,00 |
101 | 1420110 | DO50 | 2016 | 8 | 2.203,00 |
101 | 1420110 | DO50 | 2016 | 9 | 11 |
101 | 1420110 | DO50 | 2016 | 10 | 108 |
101 | 1420110 | DO50 | 2016 | 11 | 262 |
101 | 1420110 | DO50 | 2016 | 12 | 141 |
101 | 1420110 | DO50 | 2017 | 1 | 53 |
101 | 1420110 | DO50 | 2017 | 2 | 47 |
101 | 1420110 | DO50 | 2017 | 3 | 272 |
101 | 1420110 | DO50 | 2017 | 4 | 0 |
101 | 1420110 | DO50 | 2017 | 5 | 66 |
101 | 1420110 | DO50 | 2017 | 6 | 18 |
101 | 1420110 | DO50 | 2017 | 7 | 30 |
101 | 1420110 | DO50 | 2017 | 8 | 0 |
101 | 1420110 | DO50 | 2017 | 9 | 0 |
101 | 1420110 | DO50 | 2017 | 10 | 0 |
101 | 1420110 | DO50 | 2017 | 11 | 0 |
101 | 1420110 | DO50 | 2017 | 12 | 134 |
101 | 1420110 | DO50 | 2018 | 1 | 0 |
101 | 1420110 | DO50 | 2018 | 2 | 0 |
101 | 1420110 | DO50 | 2018 | 3 | 66 |
101 | 1420110 | DO50 | 2018 | 4 | 0 |
Solved! Go to Solution.
@anandav wrote:
Please check the Example 2 in the below blog:
https://whatthetechisthat.wordpress.com/2018/05/18/filling-missing-value-between-dates/
In your case since you have end of month date, you can use that instead of creating a new date field as explained in the article. Make sure in Power BI your end of month field is of Date type.
If this solves your problem please mark this as the solution.
Thanks for the link!
I've made few adjustments, and information is properly filled!
This should be the final code for this problem:
Z_StockPositionHL_Adjusted =
Var DateLastPopulated = CALCULATE (LASTNONBLANK ( 'Z1_Cross-Date_Mat'[Z_EndOfMOnth], 1 ), FILTER (ALLEXCEPT ( 'Z1_Cross-Date_Mat', 'Z1_Cross-Date_Mat'[Y_MANDT_WERKS_MATNR] ), 'Z1_Cross-Date_Mat'[Z_EndOfMOnth] < EARLIER ('Z1_Cross-Date_Mat'[Z_EndOfMOnth] ) && NOT ( ISBLANK ( 'Z1_Cross-Date_Mat'[Z_StockPositionHL]))))
Var Amount = CALCULATE(Sum('Z1_Cross-Date_Mat'[Z_StockPositionHL]), Filter(ALLEXCEPT ( 'Z1_Cross-Date_Mat', 'Z1_Cross-Date_Mat'[Y_MANDT_WERKS_MATNR] ), DateLastPopulated='Z1_Cross-Date_Mat'[Z_EndOfMOnth]))
Return If(ISBLANK('Z1_Cross-Date_Mat'[Z_StockPositionHL]),Amount,'Z1_Cross-Date_Mat'[Z_StockPositionHL])
hi, can you share how the above solution can work in my scenario?
i need to get the value for specific period using slicer - e.g. 31/12/2020
my data table only stores the period when the value last changed:
my dashboard should show:
thanks!
Check whether the below thread answered by Eric_Zhang could be of help
Hey, thanks for the reply. I've used this solution, but still not being calculating well, but almost there.
Look image below:
A = Correclty Calculating the Filling Formula.
B = It is not considering 0.00 as a non-Blank, and replacing it with upper value.
C = It is using the 8000.5 to fill where it should be 320.
Please check the Example 2 in the below blog:
https://whatthetechisthat.wordpress.com/2018/05/18/filling-missing-value-between-dates/
In your case since you have end of month date, you can use that instead of creating a new date field as explained in the article. Make sure in Power BI your end of month field is of Date type.
If this solves your problem please mark this as the solution.
@anandav wrote:
Please check the Example 2 in the below blog:
https://whatthetechisthat.wordpress.com/2018/05/18/filling-missing-value-between-dates/
In your case since you have end of month date, you can use that instead of creating a new date field as explained in the article. Make sure in Power BI your end of month field is of Date type.
If this solves your problem please mark this as the solution.
Thanks for the link!
I've made few adjustments, and information is properly filled!
This should be the final code for this problem:
Z_StockPositionHL_Adjusted =
Var DateLastPopulated = CALCULATE (LASTNONBLANK ( 'Z1_Cross-Date_Mat'[Z_EndOfMOnth], 1 ), FILTER (ALLEXCEPT ( 'Z1_Cross-Date_Mat', 'Z1_Cross-Date_Mat'[Y_MANDT_WERKS_MATNR] ), 'Z1_Cross-Date_Mat'[Z_EndOfMOnth] < EARLIER ('Z1_Cross-Date_Mat'[Z_EndOfMOnth] ) && NOT ( ISBLANK ( 'Z1_Cross-Date_Mat'[Z_StockPositionHL]))))
Var Amount = CALCULATE(Sum('Z1_Cross-Date_Mat'[Z_StockPositionHL]), Filter(ALLEXCEPT ( 'Z1_Cross-Date_Mat', 'Z1_Cross-Date_Mat'[Y_MANDT_WERKS_MATNR] ), DateLastPopulated='Z1_Cross-Date_Mat'[Z_EndOfMOnth]))
Return If(ISBLANK('Z1_Cross-Date_Mat'[Z_StockPositionHL]),Amount,'Z1_Cross-Date_Mat'[Z_StockPositionHL])
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
75 | |
63 | |
51 | |
48 |
User | Count |
---|---|
211 | |
86 | |
64 | |
59 | |
56 |