cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
erhan_79
Post Prodigy
Post Prodigy

measure help

hi there 

 

i need your support about to create a measure 

 

you can see below rule about that measure 

 

i have date column , the measure must work beased on that column : 

 

if the date column is current month it will write "Actual Month "

if the date column is before than current month  it will write  " Previous Month "

if the date column is after  than current month  it will write  " Next  Month "

 

sample : 

 

Current Month : September

 

01.10.2019--Previous Month

01.05.2020--Previous Month

01.08.2020-Previous Month

10.10.2020-Next Month

10.01.2021-NExt Month 

 

1 ACCEPTED SOLUTION

@erhan_79 

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...


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@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]
)



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

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 

@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"
    )

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

thank you @Greg_Deckler  

 

but i want to create a mesure your sample is dax formula 

could you pls help about measure too

@erhan_79 

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...


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

thank you very much @Greg_Deckler 

 

it is working 

 

following you from tweeter too 🙂

 

i wish you success in your business always!you are very helpful

 

 

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors