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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
simrantuli
Continued Contributor
Continued Contributor

Division based on condition

Hi All,

I have to calculate Area per Headcount in my Report for sites and buildings. However, I have area for some sites and headcount also for only some sites.

I have 2 tables. One is People Report and the other table is Area Report.

People Report:

simrantuli_2-1608228413421.png

#Key is a custom column which I created by merging Site code and Building.

Area Report:

simrantuli_3-1608228472675.png

There's a third table too (Dimension Table) which contains only 1 column i.e. #Key (merge of Site & Building)

My data model looks like below.

Capture1.PNG

I am using the below dax to calculate Area per Person.

Capture2.PNG

And my table in the front end looks like below.

Capture3.PNG

It's good so far. However, I want to show Area per Person in a Card basis Area & Headcount of those sites and buildings for which both are available i.e. Area per Person basis AA##1, AA##2, AB##1, AC##2 in the above image.

Please help!

Link to PBIX: https://drive.google.com/file/d/1EmwvQg0NAh6UCgPE9CBgMYpE14Pc32Bx/view?usp=sharing

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @simrantuli ,

 

Please check if this is what you want:

card.jpg

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

View solution in original post

6 REPLIES 6
Icey
Community Support
Community Support

Hi @simrantuli ,

 

Please check if this is what you want:

card.jpg

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

littlemojopuppy
Community Champion
Community Champion

VAR	HeadcountAvailable = ISBLANK(SUM(Headcount))
VAR	AreAvailable = ISBLANK(SUM(Area))
RETURN

IF(
	AND(
		HeadCountAvailable = FALSE(),
		AreaAvailable = FALSE()
	),
	DIVIDE(
		SUM([Area]),
		SUM([Headcount]),
		BLANK()
	),
	BLANK()
)
littlemojopuppy
Community Champion
Community Champion

This doesn't work?

DIVIDE(
	SUM([Area]),
	SUM([Headcount]),
	BLANK()
)

Hi @littlemojopuppy ,

I want to divide them only if both area & headcount are available in that particular site & building combination. Any thoughts on how we can achieve it?

Create two variables, in each check that numerator and demonimator are not blank.  Then check that both are true, and if so divide

I am sorry if I am asking for too much but can you please write the dax for me. I am very new to Dax. It would be a great help to me. Thanks.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.