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

need help with Lastnonblank in inventory problem

I have a case as shown in the attached table. The red number is the inventorying amount. If the following month has no inventory then it should be like the last month, until a new inventory value and the following months will be the previous month value (the black italic). I would like to see the storage development as the chat shows.

I used:

InventoryAmount =
SUMX (
VALUES ( Table[Item);
CALCULATE (
SUM (Table[Amount]);
CALCULATETABLE(
LASTNONBLANK(
Table[InventoryMonth];
CALCULATE( COUNTROWS(Table) )
);
DATESBETWEEN(
Table[InventoryMonth];
BLANK();
Max(Table[InventoryMonth])
)
)
)
)

But I only get the red numbers column sum, not the black ones.

All helps are appreciated. Thanks in advance.b1.JPGb2.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Great!

I really appreaciate your quick and working solution!

Thanks super Datanaut!

Dav - a to be Datanaut

Smiley Happy

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I have a case as shown in the attached table. The red number is the inventorying amount. If the following month has no inventory then it should be like the last month, until a new inventory value and the following months will be the previous month value (the black italic). I would like to see the storage development as the chat shows.

I used:

InventoryAmount =
SUMX (
VALUES ( Table[Item);
CALCULATE (
SUM (Table[Amount]);
CALCULATETABLE(
LASTNONBLANK(
Table[InventoryMonth];
CALCULATE( COUNTROWS(Table) )
);
DATESBETWEEN(
Table[InventoryMonth];
BLANK();
Max(Table[InventoryMonth])
)
)
)
)

But I only get the red numbers column sum, not the black ones.

All helps are appreciated. Thanks in advance.b1.JPGb2.JPG

MFelix
Super User
Super User

Hi @Anonymous,

 

Your measure is correct however in order to make it work you need to create a dimension table for Items and another one for the months.« your formula should look like this after that table is made and use on your matrix visual then add the following measure to your model:

 

 

InventoryAmount = 
SUMX (
    VALUES ( items[Item] );
    CALCULATE (
        SUM ( 'Table'[Amount] );
        CALCULATETABLE (
            LASTNONBLANK (
                'Table 2'[InventoryMonth];
                CALCULATE ( COUNTROWS ( 'Table' ) )
            );
            DATESBETWEEN (
                'Table 2'[InventoryMonth];
                BLANK ();
                MAX ('Table 2'[InventoryMonth] )
            )
        )
    )
) + 0

 

This will give you the result below:

inventory.png

Check the pbix file attach.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Great!

I really appreaciate your quick and working solution!

Thanks super Datanaut!

Dav - a to be Datanaut

Smiley Happy

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.