cancel
Showing results for
Did you mean:
Post Partisan

## Date Filter - Issue

Hi Team,

I need "Balance" formula based on dynamic date slicer, based on one condition Date filter.
Balance = [Prod_Stock]-[Prod_Val]

Note: Prod_Val sum of Date slicer, ex:  if I select different month then till the month total Prod_Val - Prod_Stock.

Thanks,

KV's

1 ACCEPTED SOLUTION
Community Support

Hi @Udt_KV

``````Balance =
VAR _T =
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[UID],
'Table'[Category],
'Table'[Prod_Val],
'Table'[Prod_Stock]
)
VAR _T2 =
ADDCOLUMNS ( _T, "Sum", SUMX ( _T, [Prod_Val] ) )
VAR _SumProd_Val =
SUMX ( _T2, [Prod_Val] )
VAR _TotalVal =
SUMX ( _T2, [Sum] )
VAR _TotalStock =
SUMX ( _T, [Prod_Stock] )
RETURN
IF (
HASONEVALUE ( 'Table'[UID] ),
_SumProd_Val - SUM ( 'Table'[Prod_Stock] ),
_TotalVal - _TotalStock
)``````

Result is as below.

Or you can build a Date table by calendar function.

``Date = calendar(Date(2020,01,12),Date(2020,06,10))``

Then use filter like filter(All(Table),table[Date]<=Max(Date[Date])).

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.

5 REPLIES 5
Community Support

Hi @Udt_KV

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

Best Regards,

Rico Zhou

Community Support

Hi @Udt_KV

``````Balance =
VAR _T =
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[UID],
'Table'[Category],
'Table'[Prod_Val],
'Table'[Prod_Stock]
)
VAR _T2 =
ADDCOLUMNS ( _T, "Sum", SUMX ( _T, [Prod_Val] ) )
VAR _SumProd_Val =
SUMX ( _T2, [Prod_Val] )
VAR _TotalVal =
SUMX ( _T2, [Sum] )
VAR _TotalStock =
SUMX ( _T, [Prod_Stock] )
RETURN
IF (
HASONEVALUE ( 'Table'[UID] ),
_SumProd_Val - SUM ( 'Table'[Prod_Stock] ),
_TotalVal - _TotalStock
)``````

Result is as below.

Or you can build a Date table by calendar function.

``Date = calendar(Date(2020,01,12),Date(2020,06,10))``

Then use filter like filter(All(Table),table[Date]<=Max(Date[Date])).

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.

Super User IV

@Udt_KV , Try a measure like

balance = [Prod Stock]- calculate([Prod_Val], allselected(Table))

Assumed [Prod_Val] and [Prod Stock] are measures

Proud to be a Super User!

Super User IV

@Udt_KV , Not very clear. You are using a before slicer. It should work. What is the problem

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Proud to be a Super User!

Post Partisan

Hi @amitchandak ,

"Prod_Val " total sum based on select month, for ex : below I have selected Feb month and till "Prod_Val total sum 23, so "Balance"  formula is 23-each row "Prod_Stock" , see the Yellow highlited column.

Announcements