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
Anonymous
Not applicable

The total during 12 months

Hi

I'm trying figure out how can I caculate the total of points within 12 months. If the total is above certain limit (e.g. 50), then I want to create an alert.

 

Example below:

Person A has total point 15 in 12 months ==> No Alert

Person B has total 30 points in 12 months. ==> No Alert

Person C has total 55 points in 12 months. ==> Alert

Person D has total of 70 points, but NOT in 12 months, but in 13 months. ==> No Alert

 

How can I achieve this?

Thanks in advance

 

YJAMOUS_2-1604089621602.png

 

 

 

1 ACCEPTED SOLUTION

@Anonymous 

You can use this measure in the visual as described earlier:

Measure points = 
VAR pointsLastDate_ =
    SUMX (
        ADDCOLUMNS (
            ADDCOLUMNS(DISTINCT(Table1[Name]),"LastDate", CALCULATE(MAX(Table1[Date]))),
            "Res",
                VAR aux_ = [LastDate]
                RETURN
                            CALCULATE (
                                SUM ( Table1[Received points] ),
                                Table1[Date] >= DATE ( YEAR ( aux_ ) - 1, MONTH ( aux_ ), DAY ( aux_ ) ),
                                Table1[Date] <= aux_,
                                ALLEXCEPT ( Table1, Table1[Name] )
                            ) 
        ),
        [Res]
    ) 
RETURN
    pointsLastDate_

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

9 REPLIES 9
AlB
Super User
Super User

@Anonymous 

 

1. Place Table1[Name] in a table visual

2. Create this measure and place it in the visual

 

Measure = 
VAR limit_ = 50 // Update as required
VAR check_ =
    SUMX (
        ADDCOLUMNS (
            Table1,
            "Res",
                VAR aux_ = Table1[Date]
                RETURN
                    1 * (
                            CALCULATE (
                                SUM ( Table1[Received points] ),
                                Table1[Date] >= DATE ( YEAR ( aux_ ) - 1, MONTH ( aux_ ), DAY ( aux_ ) ),
                                Table1[Date] <= aux_,
                                ALLEXCEPT ( Table1, Table1[Name] )
                            ) > limit_
                        )
        ),
        [Res]
    ) > 0
RETURN
    IF ( check_, "ALERT", "No alert" )

 

3. See it all at work in the attached file.

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

@AlB Thank you

I think I missed to say something
I don't want to show Alert. I'll handle the alert in traffic light. But I want to create a measure that just caculate the total for the 12 months.

@Anonymous 

What's the total for 12 months? Given a name, there's a number of points over the last 12 months for each and every date.  So you want the maximum of those? if not, what exactly?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

So, I want to create a table that will look like this:

NamePoints in 12 months
Person A15
Person B30
Person C55
Person D30

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Anonymous 

You can use this measure in the visual as described earlier:

Measure points = 
VAR pointsLastDate_ =
    SUMX (
        ADDCOLUMNS (
            ADDCOLUMNS(DISTINCT(Table1[Name]),"LastDate", CALCULATE(MAX(Table1[Date]))),
            "Res",
                VAR aux_ = [LastDate]
                RETURN
                            CALCULATE (
                                SUM ( Table1[Received points] ),
                                Table1[Date] >= DATE ( YEAR ( aux_ ) - 1, MONTH ( aux_ ), DAY ( aux_ ) ),
                                Table1[Date] <= aux_,
                                ALLEXCEPT ( Table1, Table1[Name] )
                            ) 
        ),
        [Res]
    ) 
RETURN
    pointsLastDate_

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

@Anonymous 

or if you want the result in an actual table, create a new calculated table:

 

New table points =
ADDCOLUMNS (
    ADDCOLUMNS (
        DISTINCT ( Table1[Name] ),
        "LastDate", CALCULATE ( MAX ( Table1[Date] ) )
    ),
    "Points in 12 months",
        VAR aux_ = [LastDate]
        RETURN
            CALCULATE (
                SUM ( Table1[Received points] ),
                Table1[Date]
                    >= DATE ( YEAR ( aux_ ) - 1, MONTH ( aux_ ), DAY ( aux_ ) ),
                Table1[Date] <= aux_,
                ALLEXCEPT ( Table1, Table1[Name] )
            )
)

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

AlB
Super User
Super User

Hi @Anonymous 

Are you looking to check if the person was above the points limit in any 12 month period?

Can you sahare the sampel data not in a screen cap but in text-tabular format so that it can be copied?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @AlB 

Yes, I'm looking to check if the person was above the points limit in any 12 month period.

Is this format good?

NameReceived pointsDate (DD/MM/YYYY)
Person A101/10/2019
Person B205/11/2019
Person C301/5/2019
Person D401/4/2019
Person A51/9/2020
Person B101/7/2020
Person C251/4/2020
Person D301/5/2020

 

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.

Top Solution Authors