cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jdugas
Helper I
Helper I

Help with Monthly Numbers

Hi

 

New to Power BI so forgive me if this is simple...

 

I have data that looks like this:

 

Date | Code | Code2 | Value

1/1/2016 | MGH | TPN | 56

1/1/2016 | MMC | TPN | 45

1/1/2016 | CMC | TPN | 40

2/1/2016 | MGH | TPN | 76

2/1/2016 | MMC | TPN | 87

2/1/2016 | CMC | TPN | 56

1/1/2016 | MGH | ABT | 77

1/1/2016 | MMC | ABT | 87

1/1/2016 | CMC | ABT | 57

2/1/2016 | MGH | ABT | 78

2/1/2016 | MMC | ABT | 89

2/1/2016 | CMC | ABT | 59

 

The Value field is that months target number for CODE and CODE2. At the Month view the numbers are correct but at the Quarter and Year they are not as it is summing these numbers and what I really need to do is SUM the numbers for the latest date. For example, if the above dataset is all I have, for the year view I would like to show only the sum of the February numbers as this is the lastes date for the year for the dataset.

 

Not sure if I explained myself well enough but perhaps someone will understand! Thanks for any help.

 

Jeremy

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft
Microsoft

@jdugas

 

In addition to Habib's solution, you can also use LASTDATE function to get the last date in the Quarter and Year. See my sample below.

 

I assume you have a table called "MyTestTable" like below.

t1.PNG

Then you should be able to use the formula below to create a new measure to SUM the Value for the latest date and show it on the report.

Measure 2 = CALCULATE ( SUM ( MyTestTable[Value] ), LASTDATE ( MyTestTable[Date] ) )

result.PNG

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft
Microsoft

@jdugas

 

In addition to Habib's solution, you can also use LASTDATE function to get the last date in the Quarter and Year. See my sample below.

 

I assume you have a table called "MyTestTable" like below.

t1.PNG

Then you should be able to use the formula below to create a new measure to SUM the Value for the latest date and show it on the report.

Measure 2 = CALCULATE ( SUM ( MyTestTable[Value] ), LASTDATE ( MyTestTable[Date] ) )

result.PNG

 

Regards

View solution in original post

Habib
Responsive Resident
Responsive Resident

You can achieve this by adding a new measure using below formula. I have named dataset as "Sample" in below DAX.

 

Measure = CALCULATE(SUM('Sample'[Value]),FILTER('Sample','Sample'[Date]=MAX('Sample'[Date])),ALLSELECTED('Sample'))

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors