cancel
Showing results for
Did you mean:

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

## Assign a value to a field depending on a condition and display the column total

Good team I would like to help me with the following situation:

I have 2 measures called Sales 2021 and Sales 22. I made a measure called opportunity 2022 in which I want to put the sales of the products that were sold in 2021 but in 2022 they were not had. This measure gives me what I want to do but does not show me the total.

Opportunity 2022 = CALCULATE(IF([Sales 2022]=0,[Sales 2021]))

As you can see it does not show me the total and I would like it to appear.

1 ACCEPTED SOLUTION
Community Support

Based on your description, I have created a simple sample:

``````Measure =
var _a = SUMMARIZE('Table','Table'[ID],'Table'[Sales 2021],'Table'[Sales 2022],"value",IF([Sales 2022]=0,[Sales 2021]))
return SUMX(_a,[value])``````

Final output:

Best Regards,

Jianbo Li

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

2 REPLIES 2
Community Support

Based on your description, I have created a simple sample:

``````Measure =
var _a = SUMMARIZE('Table','Table'[ID],'Table'[Sales 2021],'Table'[Sales 2022],"value",IF([Sales 2022]=0,[Sales 2021]))
return SUMX(_a,[value])``````

Final output:

Best Regards,

Jianbo Li

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

Super User

Hi,

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors