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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
wesen
Helper I
Helper I

An aggregate of latest value

Currently, am working on the report server and am collecting data on cumulative bases which mean every district report it cumulative performances. My database has three different tables one for the performance, one for the date and the other Is for the district. So that my power bi takes the sum of the aggregate of all district under a region. But I need an aggregate of last value from each district summed up, instead of all the value under a district. How can I do that?

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @wesen 

 

Please, can you share some data sample? Also, you can read this article it will help you to get questions answered faster.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

@ thanks for your quick response and I don't know how much I am clear. I tried to depict it here.  

 

Here is some description of the problem that I mentioned before. 

My_Issue.PNG

Mariusz
Community Champion
Community Champion

Hi @wesen 

 

The attached file, let me know if it works for you.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Mariusz
Community Champion
Community Champion

Hi @wesen 

 

The below will fix the total.

Value 2 = 
SUMX(
    GROUPBY( 
        'Table 1', 
        'Table 1'[District Name],
        'Table 1'[country Name] ), 
    CALCULATE( 
        SUM( 'Table 1'[Value] ),
        LASTDATE( 'Table 2'[Entry_Date] ) )
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

@Mariusz It works for imported mode and thanks to you. But am using direct query mode(In power bi server) in which I'm unable to get DAX for GROUP BY AND LAST DATE. Can you suggest me any other solution?

 

Thanks a lot,  

Mariusz
Community Champion
Community Champion

Hi @wesen 

 

 

Unfortunately, I'm not familiar with PIRS, I tried to find DAX functions supported and there is not much around.

The below is using SUMMARIZE instead of GROUPBY and MAX Instead LASTDATE, check if thats any better.

Value 3 = 
VAR _tbl = 
    ADDCOLUMNS(
        SUMMARIZE( 
            'Table 1', 
            'Table 1'[District Name],
            'Table 1'[country Name] ),
        "Max Date", CALCULATE( MAX( 'Table 2'[Entry_Date] ) ) 
    )
RETURN 
    CALCULATE( 
        SUM( 'Table 1'[Value] ),
        TREATAS( 
            _tbl, 
            'Table 1'[District Name], 
            'Table 1'[country Name], 
            'Table 2'[Entry_Date]
        )
    )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Hi@Mariusz
I attached a link to the file. Can you share it with someone who is an expert in power bi report server

Sample data from direct quire mode

Thank you for your support,

Much Appreciate

Thank you.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.