Forum Discussion
PowerBI - visualization settings issue
- Anonymous2 years ago
Hi Yaru
Based on the current data you show, you can also try this measure and use it in your donut chart visual. The logic to get the last month is through the _lastMonth variable which gets the last date in your table and convert it into yyyymm format.
UserCount Measure = var _lastMonth = FORMAT(MAX('Table'[Date]),"yyyymm") return IF(ISFILTERED('Table'[Date]),SUM('Table'[Users Counts]),CALCULATE(SUM('Table'[Users Counts]),FORMAT('Table'[Date],"yyyymm")=_lastMonth))Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
you would want to use either ISFILTERED or HASONEVALUE (personally I would use ISFILTERED):
https://learn.microsoft.com/en-us/dax/isfiltered-function-dax
This is a quick throw together but your code will look something like this:
Users =
// Gets the Start of Last Month
VAR __MinDate =
EOMONTH ( TODAY (), -2 ) + 1
// Gets the End of Last Month
VAR __MaxDate =
EOMONTH ( TODAY (), -1 )
// if Date is selected, Sums user counts. If no date selected, Returns Last Month's users count.
RETURN
IF (
ISFILTERED ( [Date] ),
SUM ( [Users Counts] ),
CALCULATE (
SUM ( [Users Counts] ),
FILTER ( 'Trends', Date >= __MinDate && Date <= __MaxDate )
)
)
- Yaru2 years agoRegular Visitor
Hello Dear,
Your suggestion is very advanced, maybe I didn't adjust it well in usage. After trying, I found that there is no data displayed when clicking on months other than June. However, when not selecting any month, the data displayed is the same as the last month. Anyway, I still want to thank you.
Best Regards,
Sherry