Forum Discussion
Balhemkan
3 years agoHelper III
Sum and average based on selection
Hello Team, I need your help on below issue. Please help me I am using date slicer (start date and end date) in my dashboard my problem is, If i select only one month in slicer it shou...
- Anonymous3 years ago
Hi Balhemkan ,
The measure calculates based on the date column. There is no date on the card so that it is blank. You can use KPI visual to show.
Or use another measure in the card.
Measure2 = VAR _min = MIN ( 'Table'[Date] ) VAR _max = MAX ( 'Table'[Date] ) VAR _sales = CALCULATE ( SUM ( volume[Sales] ), FILTER ( volume, volume[month] = MONTH ( _min ) ) ) VAR _diff = DATEDIFF ( _min, _max, MONTH ) + 1 RETURN _sales / _diffBest Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Jihwan_Kim
3 years agoSuper User
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
Expected result measure: =
VAR _calendartable =
SUMMARIZE ( 'Calendar', 'Calendar'[Month] )
VAR _monthlyqty =
ADDCOLUMNS (
_calendartable,
"@qty",
CALCULATE (
SUM ( Sales[Quantity] ),
ALLEXCEPT ( 'Calendar', 'Calendar'[Month Name], 'Calendar'[Month] )
)
)
RETURN
SWITCH (
TRUE (),
COUNTROWS ( _calendartable ) = 1, SUMX ( _monthlyqty, [@qty] ),
COUNTROWS ( _calendartable ) > 1, AVERAGEX ( _monthlyqty, [@qty] )
)