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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
huva
Frequent Visitor

how to divide cells not column

Hi There,

I need to calculate education transition rate and I have to divide students enrolled in 2014 by students enrolled in 2014. I cannot divide one ColumnC by ColumnB I need to divide cells. Below is an excel snapshot of what I want. I hope it makes is clear.

 

Thank you,transition rate.png

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @huva 

Please see the below, this should work.

Column = 
VAR _prevYear = 'transition'[Year] - 1
VAR _prevG1 =
CALCULATE(
    SELECTEDVALUE( 'transition'[9_students] ),
    ALLEXCEPT( 'transition', transition[Region] ),
    'transition'[Year] = _prevYear
)
RETURN DIVIDE( 'transition'[10_students], _prevG1 )  

The problem was that the formula was expecting one value in "SELECTEDVALUE" but was receiving multiple for each region in a year, now I've reintroduced a filter on the Region wit ALLEXCEPT, so we are returning a single value for previous year within each region. 

Hope this make sense.

Best Regards,
Mariusz

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

Please feel free to connect with me.
Mariusz Repczynski

 

 

View solution in original post

10 REPLIES 10
Mariusz
Community Champion
Community Champion

Hi @huva 

You can add a column to your table with the below DAX expression.

Column = 
VAR _prevYear = 'Table'[Year] - 1
VAR _prevG1 =
CALCULATE(
    SELECTEDVALUE( 'Table'[grade 1] ),
    ALL( 'Table' ),
    'Table'[Year] = _prevYear
)
RETURN DIVIDE( 'Table'[grade 2], _prevG1 )  
Best Regards,
Mariusz

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

Please feel free to connect with me.
Mariusz Repczynski

 

huva
Frequent Visitor

@Mariusz thanks, but it did not work. The created column was empty. 

Mariusz
Community Champion
Community Champion

Hi @huva 

Can you share your DAX expression?

The below is what I'm getting.

Column = 
VAR _prevYear = 'Table'[Year] - 1
VAR _prevG1 =
CALCULATE(
    SELECTEDVALUE( 'Table'[grade 1] ),
    ALL( 'Table' ),
    'Table'[Year] = _prevYear
)
RETURN DIVIDE( 'Table'[grade 2], _prevG1 )  
Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Mariusz
Community Champion
Community Champion

Hi @huva 

Sorry, this is what I'm getting.

image.png

huva
Frequent Visitor

@Mariusz 

Below is my DAX expression, my 'Table' is 'transition' and the grade 1 = 9_grade , grade 2 = 10_grade 

 

Column =
VAR _prevYear = 'transition'[Year] - 1
VAR _prevG1 =
CALCULATE(
SELECTEDVALUE( 'transition'[9_students] ),
ALL( 'transition' ),
'transition'[Year] = _prevYear
)
RETURN DIVIDE( 'transition'[10_students], _prevG1 )
 
thanks, 
Huva
Mariusz
Community Champion
Community Champion

Hi @huva 

Will there be duplicates years? If so it would blank the output as it is expecting only one value.

please see the below for ref
image.png

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski



huva
Frequent Visitor

Yes, it is divided into Regions and Districts so there is duplication of years. Sorry, I am new to Power BI and thaught if DAX works for a smaller table will work for bigger as well. Also wanted to mention that my 'transition' table has more columns, could this be a reason that the DAX is not working? 

 

here the table by regions

thanks, 

 

RegionYear9_students10_students
Rigion120133766621010
Rigion120143962322434
Rigion120154074724897
Rigion120163743426867
Rigion120173410122786
Rigion120183627326248
Region220131605410790
Region220141651611079
Region220151717411592
Region220161624512082
Region22017100457119
Region220181552911526
Region3201339013716
Region3201435543558
Region3201533013308
Region3201630823091
Region3201729672785
Region3201829762751
Region420136195547114
Region420146401350229
Region420156280251827
Region420165834051512
Region420176189848811
Region420185901451823
Region520134331134915
Region520144389734360
Region520154263936111
Region520164221036588
Region520175375243170
Region520184274435940
Mariusz
Community Champion
Community Champion

Hi @huva 

Please see the below, this should work.

Column = 
VAR _prevYear = 'transition'[Year] - 1
VAR _prevG1 =
CALCULATE(
    SELECTEDVALUE( 'transition'[9_students] ),
    ALLEXCEPT( 'transition', transition[Region] ),
    'transition'[Year] = _prevYear
)
RETURN DIVIDE( 'transition'[10_students], _prevG1 )  

The problem was that the formula was expecting one value in "SELECTEDVALUE" but was receiving multiple for each region in a year, now I've reintroduced a filter on the Region wit ALLEXCEPT, so we are returning a single value for previous year within each region. 

Hope this make sense.

Best Regards,
Mariusz

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

Please feel free to connect with me.
Mariusz Repczynski

 

 

huva
Frequent Visitor

Hi @Mariusz 

 

It worked with the regional data, but when I used it in the regional and district level data with over 700 rows it did not work, but after amending it slightly it perfectly worked. I removed the SELECTEDVALUE and instead used the calculated measure. here is what the final version of the DAX:

Column = 
VAR _prevYear = 'transition'[Year] - 1
VAR _prevG1 =
CALCULATE(
    [nine grade enrolled],
    ALLEXCEPT( 'transition', transition[Region] ),
    'transition'[Year] = _prevYear
)
RETURN DIVIDE( 'transition'[10_students], _prevG1 )

So thank you very much @Mariusz for your help.

 

Regards,

huva  

Mariusz
Community Champion
Community Champion

Hi @huva 

Always happy to help!

Glad you worked it out.

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.