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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Isildur13
Frequent Visitor

Calculate total on each row based on year

Hi Community

 

I need help with calculating the total amount for the whole year and display it on the rows in my table. I have no date table since the data only includes a year column.

 

I have tried to do the following in DAX:

$ Total Amount Year =
    CALCULATE (
        [$ Amount],
        FILTER (
            ALLSELECTED(  'Periode'[Year]),
            [Year] = Periode[Year]
        )
    )

 

 

But it still filters out the amount on each rows instead of showing the total for the year. Is it possible to do without a date table? 

 

Isildur13_0-1706086272931.png

 

1 ACCEPTED SOLUTION

@Isildur13 

try this : 

$ Total Amount last Year =
var  last_year =  max( period[year])   - 1 
    CALCULATE (
        [$ Amount],
        all( table_name), 
period([year]) = last_year
    )
 
 
 
 
 
 
 
 
If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. Dont forget to hit that  thumbs up button 🫡👍

View solution in original post

4 REPLIES 4
Daniel29195
Super User
Super User

@Isildur13 

 

$ Total Amount Year =
    CALCULATE (
        [$ Amount],
        allexcept( table_name ,   Periode[Year] ) 
    )
 
 
or : 

 
$ Total Amount Year =
    CALCULATE (
        [$ Amount],
        all( table_name), 
values ( period[year])  
    )
 
 
 
If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. Dont forget to hit that  thumbs up button 🫡👍
 

Hi @Daniel29195 

 

It worked! 

I went with the second solution and added one more values field.

 

I have one more question:

Is it possible to add another measure where the totals just calculated is shown like a last year? So the total amount year for category A 2020 367.75 would be displayed on category A 2021 instead?

 

Isildur13_0-1706102054445.png

 

@Isildur13 

try this : 

$ Total Amount last Year =
var  last_year =  max( period[year])   - 1 
    CALCULATE (
        [$ Amount],
        all( table_name), 
period([year]) = last_year
    )
 
 
 
 
 
 
 
 
If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. Dont forget to hit that  thumbs up button 🫡👍

Hi @Isildur13 ,

 

This should be what you're looking for. Feel free to provide more details about your specific scenario if you desire a different outcome.










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.