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
paulsnet1986
Helper I
Helper I

Count of Unique Values Sold Each Day Based on Sales to Date + Running Total

I am badly in need of a measure in to take the data in Table 1 and represent it as displayed in table two. Essentially I need a measure that counts sales only when the sale is of an SKU that hasn't already been sold in a prior date in the table, and then a running total of the first measure. Completely lost, any help would be greatly appreciated. Thank you.

 

Table 1

paulsnet1986_1-1635820453269.png

Table 2

paulsnet1986_0-1635820437146.png

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Unique SKU sales: =
VAR currentdate =
MAX ( Data[Date] )
VAR previousSKU =
CALCULATETABLE (
VALUES ( Data[SKU] ),
FILTER ( ALL ( Data ), Data[Date] < currentdate )
)
VAR currentSKU =
VALUES ( Data[SKU] )
VAR onlycurrentdateSKU =
EXCEPT ( currentSKU, previousSKU )
RETURN
IF ( HASONEVALUE ( Data[Date] ), COUNTROWS ( onlycurrentdateSKU ) + 0 )
 
Unique SKUs running total: =
VAR currentdate =
MAX ( Data[Date] )
RETURN
IF (
HASONEVALUE ( Data[Date] ),
CALCULATE (
COUNTROWS ( VALUES ( Data[SKU] ) ),
FILTER ( ALL ( Data ), Data[Date] <= currentdate )
)
)
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Unique SKU sales: =
VAR currentdate =
MAX ( Data[Date] )
VAR previousSKU =
CALCULATETABLE (
VALUES ( Data[SKU] ),
FILTER ( ALL ( Data ), Data[Date] < currentdate )
)
VAR currentSKU =
VALUES ( Data[SKU] )
VAR onlycurrentdateSKU =
EXCEPT ( currentSKU, previousSKU )
RETURN
IF ( HASONEVALUE ( Data[Date] ), COUNTROWS ( onlycurrentdateSKU ) + 0 )
 
Unique SKUs running total: =
VAR currentdate =
MAX ( Data[Date] )
RETURN
IF (
HASONEVALUE ( Data[Date] ),
CALCULATE (
COUNTROWS ( VALUES ( Data[SKU] ) ),
FILTER ( ALL ( Data ), Data[Date] <= currentdate )
)
)
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Beautiful, thank you so much!

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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.