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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Ackbar-Learner
Resolver I
Resolver I

Help with DAX on running total

Hi

 

So i got two measures that show the actual count per product and another that show the cumulative count per product:

AckbarLearner_0-1667909860836.png

What i need is a DAX formula that shows the Inventory RT data for all lines that are representing the product cumulative subtotals and the RevenueDataAllLines data for lines named Inventory in and Units sold.

 

The formula for RevenueDataAllLines is =sum(RevenueInputsDatabase[Value])

 

The formula for Inventory RT is

=VAR LastVisibleDate =

MAX ( BudgetCalendar[Date] )

VAR FirstVisibleDate =

MIN ( BudgetCalendar[Date] )

VAR LastDateWithSales =

CALCULATE (

MAX ( RevenueInputsDatabase[Transaction Date] ),

ALL(RevenueInputsDatabase)

)

VAR Result =

IF (

FirstVisibleDate <= LastDateWithSales,

CALCULATE (

[RevenueDataAllLines],

BudgetCalendar[Date]<= LastVisibleDate

)

)

RETURN

Result

 

Below is the result that should be displayed:

AckbarLearner_1-1667910138974.png

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
Ackbar-Learner
Resolver I
Resolver I

I used HASONEVALUE instead of isinscope! Sorry for not formatting properly the code. 

 

ProjectedInventory:=VAR Result = [InventoryRT]

RETURN

if(if(HASONEVALUE(RevenueInputsDatabase[AccountGL]),values(RevenueInputsDatabase[AccountGL]))="Inventory in", [RevenueDataAllLines],if(if(HASONEVALUE(RevenueInputsDatabase[AccountGL]),values(RevenueInputsDatabase[AccountGL]))="Units sold", [RevenueDataAllLines],Result))

View solution in original post

3 REPLIES 3
Ackbar-Learner
Resolver I
Resolver I

I used HASONEVALUE instead of isinscope! Sorry for not formatting properly the code. 

 

ProjectedInventory:=VAR Result = [InventoryRT]

RETURN

if(if(HASONEVALUE(RevenueInputsDatabase[AccountGL]),values(RevenueInputsDatabase[AccountGL]))="Inventory in", [RevenueDataAllLines],if(if(HASONEVALUE(RevenueInputsDatabase[AccountGL]),values(RevenueInputsDatabase[AccountGL]))="Units sold", [RevenueDataAllLines],Result))

Anonymous
Not applicable

Hi @Ackbar-Learner ,

 

According to your statement, I think your add [Stock Management] in Matrix Rows Fields as level1 and [Level2] column which contains data like "Inventory in" ,"Units sold" ... in Matrix Rows Fields as level2. Due to I don't know the name of [Level2], so I name it as [Level2]. Now you want to show running total in level1 and sum in level2.

Here I suggest you to try ISINSCOPE() to create a new measure based on [Inventory RT] and [RevenueDataAllLines].

New Inventory RT =
IF (
    ISINSCOPE ( [Level2] ),
    [RevenueDataAllLines],
    IF ( ISINSCOPE ( [Stock Management] ), [Inventory RT] )
)

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

@Anonymous I forgot to mention this is in powerpivot and ISINSCOPE cannot be used in powerpivot 🙁

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.