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
Anonymous
Not applicable

Need help with IF function on duplicate collums with different types

Hello 🙂

 

I am very new to Power BI and still learning.

I have been helped with most things on this forum from looking around, but iv faced an obstical i havent seen out there yet,

 

I need the % of shipmenst in total with just NI and just DT

And a % total with both NI and DT

These are types of shipments we get in our warehouse.

Please let me know if i need to post more information on the matter, first time poster

 

2017-06-22_09-07-48.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

I've created a sample demo file to showcase the measures you can use to accomplish your task. 

 

Here is one of the measures - counting shipments with "NI" as the only value in Type column:

 

NI = CALCULATE(
	DISTINCTCOUNT(Data[Forsendelses nr]);
	FILTER(
		Data;
		CONTAINS(
			Data;
			Data[Forsendelses nr];[Forsendelses nr];
			Data[Type];"NI"
		) && NOT(
			CONTAINS(
				Data;
				Data[Forsendelses nr];[Forsendelses nr];
				Data[Type];"DT"
			)
		)
	)
)

To count all shipments you can use the following measure: 

 

Number of Shipments = CALCULATE(DISTINCTCOUNT(Data[Forsendelses nr]);ALL(Data))

Then calculation of "NI-only" shipments is straightforward:

 

% of NI = DIVIDE([NI];[Number of Shipments]) 

You can download a sample .pbix file here: http://blog.sqlgeek.pl/Download/DAX - Count with EXISTS.pbix.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi,

 

I've created a sample demo file to showcase the measures you can use to accomplish your task. 

 

Here is one of the measures - counting shipments with "NI" as the only value in Type column:

 

NI = CALCULATE(
	DISTINCTCOUNT(Data[Forsendelses nr]);
	FILTER(
		Data;
		CONTAINS(
			Data;
			Data[Forsendelses nr];[Forsendelses nr];
			Data[Type];"NI"
		) && NOT(
			CONTAINS(
				Data;
				Data[Forsendelses nr];[Forsendelses nr];
				Data[Type];"DT"
			)
		)
	)
)

To count all shipments you can use the following measure: 

 

Number of Shipments = CALCULATE(DISTINCTCOUNT(Data[Forsendelses nr]);ALL(Data))

Then calculation of "NI-only" shipments is straightforward:

 

% of NI = DIVIDE([NI];[Number of Shipments]) 

You can download a sample .pbix file here: http://blog.sqlgeek.pl/Download/DAX - Count with EXISTS.pbix.

Anonymous
Not applicable

Wow Pawelpo!

This is relly good stuff 🙂

Thank you very mutch sir

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.