cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Measure to add Boolean values

Hello everyone

I have this case without finding a correct solution, I have two measures that add budget and shipping, I need to another extent meet a condition and add the total result

Calculations[Budget]>Calculations[Shipping],Calculations[Shipping],Calculations[Budget]
but I can't get the total sum of countable
MHR88_0-1651765510575.png

This is the code I have used.
countable =

IF(HASONEVALUE('Style by Make'[Assembly Style]),
Where P=
SWITCH(
True (),
Calculations[Budget]>Calculations[Shipping],Calculations[Shipping],
Calculations[Budget]
)
Return P

)
Someone who helps me with ideas, I will thank you eternally.
1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Syndicate_Admin 

countable =

SUMX(
	VALUES('Style by Make'[Assembly Style]),
	VAR _budget = Calculations[Budget]
	VAR _shipping = Calculations[Shipping]
	RETURN
	IF ( _budget > _shipping, _shipping, _budget )
)


In case it answered your question please mark this as a solution for community visibility. Appreciate Your Kudos 🙂

View solution in original post

6 REPLIES 6
Syndicate_Admin
Administrator
Administrator

Hello, I hope you are well,

in the model there is a calendar table, I want to show you the comparison of the result of the model vs calculated in excel, do you have any suggestions to modify the initial code?

MHR88_0-1652812784105.png

Greetings, thank you for your contribution.

SpartaBI
Community Champion
Community Champion

@Syndicate_Admin 

countable =

SUMX(
	VALUES('Style by Make'[Assembly Style]),
	VAR _budget = Calculations[Budget]
	VAR _shipping = Calculations[Shipping]
	RETURN
	IF ( _budget > _shipping, _shipping, _budget )
)


In case it answered your question please mark this as a solution for community visibility. Appreciate Your Kudos 🙂

A worked to perfection! Thank you so much.

@Syndicate_Admin my pleasure 🙂
Please don't forget to mark that reply as a solution to help other community members find it more easily. Appreciate Your Kudos.

@SpartaBI I have been presented with an error, the fault is not identified. in cases such as the following example the total value is incorrect.

MHR88_0-1651774994147.png

I have successfully added the code.

Countable = SUMX(VALUES('Style by Make'[Assembly Style]),

Where _Budget = Calculations[Budget]
Where _Shipping = Calculations[Shipping]

Return if(_Budget>_Shipping,_Shipping,_Budget))

@Syndicate_Admin so it worked on the previous table but not when you added months to the rows?

If yes, so it's because the way it calculate in the combination of months and style. In the total there is no filters, so I guess the style has values in different months, but I would also expect to see this in the visual. Very hard to say without looking at the model itself. 

Where does the column month come from? The same table?

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors