Forum Discussion
measure help
- 5 years ago
Measure = VAR __Min = DATE(YEAR(TODAY()),MONTH(TODAY()),1) VAR __Max = EOMONTH(__Min,0) RETURN SWITCH(TRUE(), MAX([Date])<__Min,"Previous Month", MAX([Date])>__Max,"Next Month", "Actual Month" )But you can't use a measure in a slicer unless you use the disconnected table trick. In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563
erhan_79 , You can try like
Month Type = Switch( True(),
eomonth(Date[Date],0) = eomonth(Today(),0) ,"Current Month" , //This Month
eomonth(Date[Date],0) < eomonth(Today(),0) && ,"Previous Month" , //last Month
eomonth(Date[Date],0) > eomonth(Today(),0) && ,"Next Month" , //last Month
[Month Year]
)
OR
//Only one month
Month Type = Switch( True(),
eomonth(Date[Date],0) = eomonth(Today(),0) ,"Current Month" , //This Month
eomonth(Date[Date],0) = eomonth(Today(),-1) && ,"Previous Month" , //last Month
eomonth(Date[Date],0) = eomonth(Today(),1) && ,"Next Month" , //last Month
[Month Year]
)
hi amitchandak
thanks for your reply but , when i write your formula after "emonth" system does not accept table name "date[date]" , system wants start date as a date
- Greg_Deckler5 years agoCommunity Champion
erhan_79 See attached PBIX below sig, Table (18)
Column = VAR __Min = DATE(YEAR(TODAY()),MONTH(TODAY()),1) VAR __Max = EOMONTH(__Min,0) RETURN SWITCH(TRUE(), [Date]<__Min,"Previous Month", [Date]>__Max,"Next Month", "Actual Month" )- erhan_795 years agoPost Prodigy
thank you Greg_Deckler
but i want to create a mesure your sample is dax formula
could you pls help about measure too
- Greg_Deckler5 years agoCommunity Champion
Measure = VAR __Min = DATE(YEAR(TODAY()),MONTH(TODAY()),1) VAR __Max = EOMONTH(__Min,0) RETURN SWITCH(TRUE(), MAX([Date])<__Min,"Previous Month", MAX([Date])>__Max,"Next Month", "Actual Month" )But you can't use a measure in a slicer unless you use the disconnected table trick. In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563