cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Udt_KV
Post Partisan
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.

 

screen.PNG

 

 

Thanks,

KV's

1 ACCEPTED SOLUTION
RicoZhou
Community Support
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.

2.png

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. 

 

 

View solution in original post

5 REPLIES 5
RicoZhou
Community Support
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

RicoZhou
Community Support
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.

2.png

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. 

 

 

View solution in original post

amitchandak
Super User IV
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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

amitchandak
Super User IV
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.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

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.

screen_II.PNG

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors