Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
snoh8r49
Frequent Visitor

Return time period of Min month and year up to last month

Currently I am able to create this for a card : 

DateText = IF(AND(SELECTEDVALUE(PERIOD_DIM[MTH],"All") ="All", SELECTEDVALUE(PERIOD_DIM[YR],"All")="All"),(MIN(PERIOD_DIM[MTH]) & "/" & MIN(PERIOD_DIM[YR]) &" - " & MAX(PERIOD_DIM[MTH]) & "/" & MAX(PERIOD_DIM[YR])),(SELECTEDVALUE(PERIOD_DIM[MTH],"All") & "-" & SELECTEDVALUE(PERIOD_DIM[YR],"All")))

 

However, the max month in my table is Sep of this year. I need to limit it to the previous month. I also want the slicer that is a Hierarchy Slicer built on MTH and YR to default to the previous month and year. That would then populate in the card. Is that possible?

1 ACCEPTED SOLUTION
snoh8r49
Frequent Visitor

I solved it with this:

DateText = IF(AND(SELECTEDVALUE(PERIOD_DIM[MTH],"All") ="All",  SELECTEDVALUE(PERIOD_DIM[YR],"All")="All"),MIN(PERIOD_DIM[MTH]) & "/" & MIN(PERIOD_DIM[YR]) & " - " & FORMAT((EOMONTH(TODAY(),-1)),"MMM/YYYY"),(SELECTEDVALUE(PERIOD_DIM[MTH],"All") &  "-" & SELECTEDVALUE(PERIOD_DIM[YR],"All")))
 
I didn't need the additional column after all. I had tried something like this before but until I saw @amitchandak's solution I didn't see where I was going wrong. 

View solution in original post

3 REPLIES 3
snoh8r49
Frequent Visitor

I solved it with this:

DateText = IF(AND(SELECTEDVALUE(PERIOD_DIM[MTH],"All") ="All",  SELECTEDVALUE(PERIOD_DIM[YR],"All")="All"),MIN(PERIOD_DIM[MTH]) & "/" & MIN(PERIOD_DIM[YR]) & " - " & FORMAT((EOMONTH(TODAY(),-1)),"MMM/YYYY"),(SELECTEDVALUE(PERIOD_DIM[MTH],"All") &  "-" & SELECTEDVALUE(PERIOD_DIM[YR],"All")))
 
I didn't need the additional column after all. I had tried something like this before but until I saw @amitchandak's solution I didn't see where I was going wrong. 
snoh8r49
Frequent Visitor

@amitchandak  How would I incorporate that to my measure?

amitchandak
Super User
Super User

@snoh8r49 , you need a column like this in your date table

 

Month Type = Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1*month(Today())),"Last year Last Month" ,
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY")
)

 

 

or

 

Month Type =

var _today =  max(Fact[Date])

Switch( True(),
eomonth([Date],0) = eomonth(_today ,-1*month(_today )),"Last year Last Month" ,
eomonth([Date],0) = eomonth(_today ,-1),"Last Month" ,
eomonth([Date],0)= eomonth(_today ,0),"This Month" ,
Format([Date],"MMM-YYYY")
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.