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
Syndicate_Admin
Administrator
Administrator

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]))
Pacifico_28_0-1669431812640.png

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

Thank you for your help

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

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

vjianbolimsft_0-1669873743503.png

Please try:

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:

vjianbolimsft_1-1669873960896.png

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.

View solution in original post

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

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

vjianbolimsft_0-1669873743503.png

Please try:

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:

vjianbolimsft_1-1669873960896.png

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.

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of your PBI file.


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

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.