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
Syndicate_Admin
Administrator
Administrator

previous month's value

Hello

I'm using the measurement below for the previous month, but when the card's visual is not selected it is displayed (blank). I want to display a constant value for the previous month and change the accordion month selection in the slicer.

please guide

Recuento de mes anterior = 
VAR __currentDate = EOMONTH ( MAX ( Sheet1[date] ), -1 )
RETURN CALCULATE ( 
    COUNTROWS ( Sheet1 ), 
    DATESBETWEEN ( Sheet1[date], 
    EOMONTH ( __currentDate, -1 ) + 1, __currentDate 
)

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

Causes of the problem:

When calculating the data for the first month, the original table does not have the data for the month before the first month

You can use the following steps:

Step 1,

Create a  date table, just like  if  the before table  date from 2020.2.1 to2021.3.1 ,then date table from 2020.1.1 to 2021.3.1

Table2 = CALENDAR(EOMONTH (MIN('Sheet1'[Date]),-2)+1,MAX(('Sheet1'[Date])))

v-luwang-msft_0-1614914402236.png

 

 

Step 2,

Use the following measure:

Recuento de mes anterior = CALCULATE (

    COUNTROWS (Table2),

    DATESBETWEEN (Table2[date],

    EOMONTH (max(Table2[Date]), -2) + 1,

    EOMONTH (max(Table2[Date]), -1)

))

v-luwang-msft_1-1614914402241.png

 

 

 

Wish it is helpful for you!

Click here to download pbix  if you need.

Best Regard

Lucien Wang

 

 

 

 

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

Causes of the problem:

When calculating the data for the first month, the original table does not have the data for the month before the first month

You can use the following steps:

Step 1,

Create a  date table, just like  if  the before table  date from 2020.2.1 to2021.3.1 ,then date table from 2020.1.1 to 2021.3.1

Table2 = CALENDAR(EOMONTH (MIN('Sheet1'[Date]),-2)+1,MAX(('Sheet1'[Date])))

v-luwang-msft_0-1614914402236.png

 

 

Step 2,

Use the following measure:

Recuento de mes anterior = CALCULATE (

    COUNTROWS (Table2),

    DATESBETWEEN (Table2[date],

    EOMONTH (max(Table2[Date]), -2) + 1,

    EOMONTH (max(Table2[Date]), -1)

))

v-luwang-msft_1-1614914402241.png

 

 

 

Wish it is helpful for you!

Click here to download pbix  if you need.

Best Regard

Lucien Wang

 

 

 

 

negi007
Community Champion
Community Champion

@Syndicate_Admin 

 

You can create a below measure to calculate previous month value

 

= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSMONTH('DateTime'[DateKey]))




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.