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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

@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
Employee
Employee

@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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.