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
Anonymous
Not applicable

Fill empty values in table

Hi,

 

I have a problem with non-listed values in a table. I have a standard timeDimension and a table with orders:

Order DateArticle NumberStockOrdered Amount
01.02.20211220020
02.02.20211218050
05.02.20211213010
06.02.20211212030

 

As you can see there are no orders on 03.02.2021 and 04.02.2021. What I need is this:

Order DateArticle NumberStockOrdered Amount
01.02.20211220020
02.02.20211218050
03.02.2021121300
04.02.2021121300
05.02.20211213010
06.02.20211212030

 

It is way more complicated than it seems. 
I am open to any solutions, whether with M, Dax, or a new table structure.

 

Thanks for your help!

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@Anonymous 

Here is one way. First the model:

model.JPG

 

now create the following measures:

1) Simple sums for stock and orders

2) The initial stock for an article:

Starting stock =
VAR StartDate =
    CALCULATE (
        FIRSTDATE ( 'Date Table'[Date] ),
        ALLEXCEPT ( FactTable, FactTable[Article Number] )
    )
RETURN
    CALCULATE (
        [Sum of Stock],
        FILTER ( ALL ( 'Date Table' ), 'Date Table'[Date] = StartDate )
    )

3) the cumulative orders:

Cumulative Orders =
CALCULATE (
    [Sum of order],
    FILTER (
        ALL ( 'Date Table' ),
        'Date Table'[Date] <= MAX ( 'Date Table'[Date] )
    )
)

4) the running stock value:

Running Stock =
CALCULATE (
    [Starting stock] - [Cumulative Orders],
    DATEADD ( 'Date Table'[Date], -1, DAY )
)

all of which are seen in the following table:calculations.JPG

and finally delete the unnecessary fields from the visual:result.JPG

(if you'd rather see 0 instead of blanks for sum of orders, simply add a 0 in the measure):

 

Sum of order = SUM(FactTable[Ordered Amount]) + 0

 

I've attached the sample PBIX for your reference





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
v-xiaoyan-msft
Community Support
Community Support

Hi@Anonymous,

 

Nice day ! Has your problem been solved? if so, please consider Accept a correct reply as the solution to help others find it.
 

Best Regards,

Caitlyn Yan

 

 

stevedep
Memorable Member
Memorable Member

Suppose you are looking for a running total?

stevedep_0-1614284295190.png

 

File is attached.

Kind regards, Steve. 

 

PaulDBrown
Community Champion
Community Champion

@Anonymous 

Here is one way. First the model:

model.JPG

 

now create the following measures:

1) Simple sums for stock and orders

2) The initial stock for an article:

Starting stock =
VAR StartDate =
    CALCULATE (
        FIRSTDATE ( 'Date Table'[Date] ),
        ALLEXCEPT ( FactTable, FactTable[Article Number] )
    )
RETURN
    CALCULATE (
        [Sum of Stock],
        FILTER ( ALL ( 'Date Table' ), 'Date Table'[Date] = StartDate )
    )

3) the cumulative orders:

Cumulative Orders =
CALCULATE (
    [Sum of order],
    FILTER (
        ALL ( 'Date Table' ),
        'Date Table'[Date] <= MAX ( 'Date Table'[Date] )
    )
)

4) the running stock value:

Running Stock =
CALCULATE (
    [Starting stock] - [Cumulative Orders],
    DATEADD ( 'Date Table'[Date], -1, DAY )
)

all of which are seen in the following table:calculations.JPG

and finally delete the unnecessary fields from the visual:result.JPG

(if you'd rather see 0 instead of blanks for sum of orders, simply add a 0 in the measure):

 

Sum of order = SUM(FactTable[Ordered Amount]) + 0

 

I've attached the sample PBIX for your reference





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Thank you PaulDBrown! This was what I needed! Had to change some little things but all in all thats it!

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Create a measure to display your [Ordered Amount] value like this:

 

 

_yourAmount = SUM(yourTable[Ordered Amount]) + 0

 

 

This will show you zeroes where no other value exists.

 

If you don't want the zeroes, you can right-click on any of your displayed dimensions and check 'Show items with no data':

BA_Pete_0-1614098251273.png 

 

However, note that this will show ALL values available in the dimensions, so may not be suitable for your use-case.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Hi Pete,
Thanks for your reply, but unfortunately this isn't what I need.  
Selecting "Show items with no data" leaves all values empty except the date.

The measure just adds rows with same date as order date but with zeros.

lh_2020

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.