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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Sudharsanan
Helper III
Helper III

Calculated column to have same value in both Rows

Hi friends,

i have below scenerio where we have Qty for 2021 and 2022 for same product. i need to have the 2022 qty in a new colum in both the rows.

 

Sudharsanan_0-1661452521028.png

Thanks for your support

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sudharsanan ,

 

Please try

2022-QTY = 
CALCULATE (
    SUM ( 'Table'[Qty] ),
    FILTER ( ALL ( 'Table'[SALES_Year] ), 'Table'[SALES_Year] = 2022 ),
    ALLEXCEPT ( 'Table', 'Table'[SALES_Mel] )
)

vcgaomsft_0-1661849297690.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

11 REPLIES 11
arvindsingh802
Super User
Super User

Use this
2022QTY =
CALCULATE(SUM('Table'[Qty]), ALL('Table'[SALES_Year]),'Table'[SALES_Year] = 2022)

If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!
Proud to be a Super User!!

Thank you @arvindsingh802 

i wanted the qty to be populated in both the rows. is it possibe?

Sudharsanan_0-1661522518819.png

 

@Sudharsanan  Please create a measure using this

2022QTY = CALCULATE(SUM('Table'[Qty]), ALL('Table'[SALES_Year]),'Table'[SALES_Year] = 2022)

this will work as required


If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!
Proud to be a Super User!!

Thanks Again @arvindsingh802 

i will brief you what i am trying to derive. in the below data set, for 1 product i have sales & qty in 2021 & 2022. like wise for all the prod. below is my logic and i should get the value 10.45%

 

=(Sum of 2022 sales) / ((sum of 2021 sales)/(sum of 2021 qty)) * sum of 2022qty)))-1

 

CustprodSalesQtyYear
1A1,193152022
1A52672021
2B1,16532022
2B77722021
3C1,02842022
3C59632021
4D80252022
4D1,389102021
5E79462022
5E92282021
6F76742022
6F17112021
7G71782022
7G4,303482021
8H49212022
8H1,35032021
9I45282022
9I19342021
10J44552022
10J22932021
11K40852022
11K1,183162021
12L37632022
12L24222021
13M35522022
13M1,42082021
14N29532022
14N27032021
15O23512022
15O57132021
16P215102022
16P1,022502021
17Q16322022
17Q1,311182021
18R11952022
18R590312021
19S7852022
19S4132021
20T6332022
20T4122021
21U6112022
21U10222021
22V4112022
22V15452021
23W2912022
23W5122021

Hello @Sudharsanan 

 

What you can possibly do is to create a single DAX with different variables of logic as mentioned above and then combine them in the return statement as per your logic.

 

Additional advice on creating a measure would have been much easier.

 

Regards,

 

IF MY SOLUTION HELPED YOU PLEASE DO HIT A LIKE AND ACCEPT IT AS A SOLUTION IF IT SOLVES YOUR ERROR!

Thank you @NimaiAhluwalia 

 

I tried my best but not able to get the number what i want, so thought of having it in the columns and use it for measures.

 

But for this issue, still i am not able to get a solution. I need the number 5 to be populated in both the rows.

 

Sudharsanan_0-1661778026892.png

 

Anonymous
Not applicable

Hi @Sudharsanan ,

 

Please try

2022-QTY = 
CALCULATE (
    SUM ( 'Table'[Qty] ),
    FILTER ( ALL ( 'Table' ), 'Table'[SALES_Year] = 2022 )
)

vcgaomsft_0-1661846806331.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

thank you @Anonymous 

 

This query gives me the sum of qty for 2022. but my requirement is as shown below.

 

i have produts for 2021 and 2022 but the qty for each prouct should be the sum of 2022's qty. i am able to get the qty for the rows with 2022, but i need the same value to be populated in the rows with 2021 as well.

 

Sudharsanan_0-1661848285793.png

 

Anonymous
Not applicable

Hi @Sudharsanan ,

 

Please try

2022-QTY = 
CALCULATE (
    SUM ( 'Table'[Qty] ),
    FILTER ( ALL ( 'Table'[SALES_Year] ), 'Table'[SALES_Year] = 2022 ),
    ALLEXCEPT ( 'Table', 'Table'[SALES_Mel] )
)

vcgaomsft_0-1661849297690.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Thanks @Anonymous  it is working now.

can you help me to build the below logic in measure?

 

 

i need to build the below logic to get the result 10.45%

 

=(Sum of 2022 sales) / ((sum of 2021 sales)/(sum of 2021 qty)) * sum of 2022qty)))-1

 

CustprodSalesQtyYear
1A1,193152022
1A52672021
2B1,16532022
2B77722021
3C1,02842022
3C59632021
4D80252022
4D1,389102021
5E79462022
5E92282021
6F76742022
6F17112021
7G71782022
7G4,303482021
8H49212022
8H1,35032021
9I45282022
9I19342021
10J44552022
10J22932021
11K40852022
11K1,183162021
12L37632022
12L24222021
13M35522022
13M1,42082021
14N29532022
14N27032021
15O23512022
15O57132021
16P215102022
16P1,022502021
17Q16322022
17Q1,311182021
18R11952022
18R590312021
19S7852022
19S4132021
20T6332022
20T4122021
21U6112022
21U10222021
22V4112022
22V15452021
23W2912022
23W5122021
Anonymous
Not applicable

Hi @Sudharsanan 

 

vcgaomsft_1-1661851886013.png

The formula you provided seems to have an extra or missing ')', please try to correct it yourself.

 

Measure = 
VAR _sum_of_2022_sales = CALCULATE(SUM('Table'[Sales]),'Table'[Year]=2022)
VAR _sum_of_2021_sales = CALCULATE(SUM('Table'[Sales]),'Table'[Year]=2021)
VAR _sum_of_2021_qty = CALCULATE(SUM('Table'[Qty]),'Table'[Year] = 2021)
VAR _sum_of_2022_qty = CALCULATE(SUM('Table'[Qty]),'Table'[Year] = 2022)
VAR _result = (_sum_of_2022_sales) / ((_sum_of_2021_sales)/(_sum_of_2021_qty)) * _sum_of_2022_qty)))-1
RETURN
_result

 

Best Regards,
Gao

Community Support Team

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors