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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
iamdmitry
Frequent Visitor

How calculate quantity difference (distinct count) between row date and selected date

Hello, guys!

 

Please, help me or give me some advice, how calculate quantity difference (distinct count) between row date and selected date.

 

For example, if selected date is 31-1-18:

 

Date       | Distinct Count ID | Diff
31-1-18  | 12                        | 0
01-2-18  | 10                        | -2
02-2-18  | 16                        | 4
03-2-18  | 22                        | 10
04-2-18  | 11                        | -1

 

Dataset is seems like:

Date | ID | Category | Type | Color | etc.

 

I need to create chart with Diff as values and Dates as time axis.
If it's possible, I would like to save possibility to use filtering by columns (Category, Type, Color...)

----------------------------------------------------------

I've calculated two measures like:

 

fixed quantity = calculate(distinctcount(ID), filter(table, Date = Date(2018, 1, 31)))
dynamic quantity = distinctcount(ID)
diff = dynamic quantity - fixed quantity

 

But that approach doesn't work ;-(

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Try:

 

fixed quantity = calculate(distinctcount(ID), filter(ALL(table), Date = Date(2018, 1, 31)))
dynamic quantity = distinctcount(ID)
diff = dynamic quantity - fixed quantity


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

Try:

 

fixed quantity = calculate(distinctcount(ID), filter(ALL(table), Date = Date(2018, 1, 31)))
dynamic quantity = distinctcount(ID)
diff = dynamic quantity - fixed quantity


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.