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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

 

 

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
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

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

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

 

 

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. 

 

 

amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

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

 

Assumed [Prod_Val] and [Prod Stock] are measures

amitchandak
Super User
Super User

@Anonymous , 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.

Anonymous
Not applicable

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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