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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
parisaranda
New Member

How to measure the sum of X table (of this semester) / the sum of X table (of the last semester)

Hello and happy thanksgiving for you all,

 

I am having this issue with this tables and the formula should be:

 

sum(Matriculados) / sum(Matriculados (semester -1))
 
But I was not able to had a proper calculation, since I am here: 
 
 Now, I have the semester as the column name "Año" where it shows as an integer the year and "Semester" that shows 1 and 2. Also, the "Matriculados" column is an integer.
 
I would be glad to know that there is a way to calculate the required formula.
 
Thank you for your time. 
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @parisaranda ,

I build a sample to have a test. Firstly add a calculated column : Rank by Year and Semester.

Rank by Year and Semester = RANKX('Table','Table'[Año]*10+'Table'[Semester],,ASC,Dense)

1.png

Measure:

Sum of X table (of this semester) / Sum of X table (of the last semester) = 
VAR _THIS_Semester =
    CALCULATE ( SUM ( 'Table'[Matriculados] ) )
VAR _LAST_Semester =
    CALCULATE (
        SUM ( 'Table'[Matriculados] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Rank by Year and Semester]
                = MAX ( 'Table'[Rank by Year and Semester] ) - 1
        )
    )
RETURN
    DIVIDE ( _THIS_Semester, _LAST_Semester )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @parisaranda ,

I build a sample to have a test. Firstly add a calculated column : Rank by Year and Semester.

Rank by Year and Semester = RANKX('Table','Table'[Año]*10+'Table'[Semester],,ASC,Dense)

1.png

Measure:

Sum of X table (of this semester) / Sum of X table (of the last semester) = 
VAR _THIS_Semester =
    CALCULATE ( SUM ( 'Table'[Matriculados] ) )
VAR _LAST_Semester =
    CALCULATE (
        SUM ( 'Table'[Matriculados] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Rank by Year and Semester]
                = MAX ( 'Table'[Rank by Year and Semester] ) - 1
        )
    )
RETURN
    DIVIDE ( _THIS_Semester, _LAST_Semester )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@parisaranda 

could you pls provide the sample data and expected output?





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

Proud to be a Super User!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

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.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.