Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
Hi,
I need to create two measures: one shows DISTINCTCOUNT(table[ID]) for every month in a year and another a cumulative sum for the same DISTINCTCOUNT(table[ID]).
I need to use TREATAS to connect a column from table to calendar.
I think I can get the correct for monthly using this:
Solved! Go to Solution.
Hi @Petja
Hi,
Does this work?
CALCULATE(DISTINCTCOUNTNOBLANK(Table[ID]),userelationship(Table[Date],Calendar[Date]),DATESYTD(Calendar[Date]))
To the visual, drag date from the Calendar table.
If it does not work, then share the download link of the PBI file.
Hey, thank you for all the replies, haven't had time to test all of them. I ended up getting coherent results with using USERELATIONSHIP() instead of TREATAS() but there was a working solution here using TREATAS().
Hi @Petja,
We would like to confirm if our community members answer resolves your query or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are happy to help you.
Thank you for your patience and look forward to hearing from you.
Best Regards,
Prashanth Are
MS Fabric community support
Hi @Petja,
We would like to confirm if our community members answer resolves your query or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are happy to help you.
@Ashish_Mathur, @Elena_Kalina, @cengizhanarslan & @krishnakanth240, thanks for your prompt response
Thank you for your patience and look forward to hearing from you.
Best Regards,
Prashanth Are
MS Fabric community support
Hi,
Does this work?
CALCULATE(DISTINCTCOUNTNOBLANK(Table[ID]),userelationship(Table[Date],Calendar[Date]),DATESYTD(Calendar[Date]))
To the visual, drag date from the Calendar table.
If it does not work, then share the download link of the PBI file.
1) Monthly DISTINCTCOUNT (per month only)
IDs (Monthly) =
CALCULATE (
DISTINCTCOUNTNOBLANK ( 'Table'[ID] ),
TREATAS ( VALUES ( 'Calendar'[Date] ), 'Table'[Date] )
)Put Calendar[Month] (or Year-Month) on the axis and this will return the distinct IDs for that month.
2) Cumulative DISTINCTCOUNT (YTD, resets each year)
IDs (Cumulative YTD) =
VAR DatesYTD =
DATESYTD ( 'Calendar'[Date] )
RETURN
CALCULATE (
DISTINCTCOUNTNOBLANK ( 'Table'[ID] ),
TREATAS ( DatesYTD, 'Table'[Date] )
)This evaluates the distinct IDs over the YTD date set, so it naturally resets in a new year (based on your Calendar).
Hi @Petja
Hi @Petja
Can you try these measures. Happy to work if you can share the sample data of 'tables' with the 'columns'. Thank You!
Monthly IDs =
CALCULATE (
DISTINCTCOUNTNOBLANK('Table'[ID]),
TREATAS(VALUES(Calendar[Date]),'Table'[Date]))
Cumulative Monthly IDs =
VAR CurrDate = MAX(Calendar[Date])
RETURN
SUMX(VALUES(Calendar[MonthYear]),
CALCULATE([Monthly IDs],Calendar[Date]<= CurrDate))
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 23 | |
| 21 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 58 | |
| 54 | |
| 42 | |
| 30 | |
| 24 |