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.
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
Solved! Go to Solution.
Hi @Anonymous
amitchandak 's measure will show correct result except in total.
If you want to show correct total, you can try my way.
My Sample Table:
Measure:
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.
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
Hi @Anonymous
amitchandak 's measure will show correct result except in total.
If you want to show correct total, you can try my way.
My Sample Table:
Measure:
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.
@Anonymous , Try a measure like
balance = [Prod Stock]- calculate([Prod_Val], allselected(Table))
Assumed [Prod_Val] and [Prod Stock] are measures
@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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |