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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jnpb
Helper I
Helper I

Have a specific field value count as one of each of two other values

I have a measure that counts rows to get a total number of orders YTD. It's built like this:

 

Orders YTD = CALCULATE(COUNT('PurchaseReport'[OrderId]),DATESYTD('PurchaseReport'[Created].[Date]))

 

A slicer in my my report then filters by a specific product category. Data is structured in this way:

 

OrderID      Product Category

23458         Apple

08821         Orange

12340         Banana

81237         Apple/Orange

58342         Apple/Banana

 

The idea being that slicing by product category gives the YTD order total per category.

 

However, we have a combination product type for which a count of 1 should be applied to both products (e.g. Apple/Orange should count as 1 count in Apple, 1 count in Orange). Since the Orders YTD simply counts the column for the total number of orders, I don't know how to work this in so that anytime a combination product type value is given, it treats each as its' own row count for that product.

 

Assuming I have to rethink how I'm tabulating orders per product type, what would be the right approach here?

 

Thanks!

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Once you have split data into rows (as suggested by FreemanZ), follow these steps

1. Create a Calendar Table

2. Create a relationship (Many to One and Single) from the Created column to the Date column of the Calendar Table

3. To your visual, drag the Date from the Created column

4. Write these measures:

Total = COUNT('PurchaseReport'[OrderId])

Total YTD = calculate([Total],datesytd(Calendar[Date],"31/12"))

Hope this helps.

 


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

hi @jnpb 

You would need to split the column to rows firstly in Power Query, like this:

https://community.powerbi.com/t5/Desktop/Power-Query-Split-data-onto-individual-rows/td-p/1928351

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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