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
Supaplex
Regular Visitor

distinctcount from past period

Hi!

 

I have an issue with distinctcount function:

We have sales table with actual data in January 2017 and January 2018.

For example:

datepoint_keyamount
01.01.2017111200
01.01.2017333100
01.01.2017222300
01.01.2017333400
01.01.2018111100
01.01.2018444400
01.01.2018555200
01.01.2018111300

 

I can take DISTINCTCOUNT of point_keys if I select filter (January 2018) in month = CALCULATE(DISTINCTCOUNT([point_key])) = 3

I can take DISTINCTCOUNT of point_keys in same month of prior year = CALCULATE(DISTINCTCOUNT([point_key]);DATEADD('Calendar'[Date];-1;YEAR)) = 3

 

The matter is how to get increment and decrement in unique point_keys between CY and PY?

in our case we can see that point_key 555 has appeared in January 2018 and point_key 222 has disappeared from January 2017.

 

Well, can I put increment and decrement into different calculated measures?

 

I've tried for increment SUMX(ADDCOLUMNS(mytable;"stream";IF(DISTINCTCOUNT([point_key]) - CALCULATE(DISTINCTCOUNT([point_key]);DATEADD('Calendar'[Date];-1;YEAR))=1;1;BLANK()));[stream])

 

but it sums rows in fact_table 😞

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi Supaplex,

 

For further test, could you please provide more details about CY , PY? In addtion,  are [stream], [increment] and [decrement] the measures you have created? Could you please clarify these measures and your expected result?

 

Regards,

Jimmy Tao

Supaplex
Regular Visitor

Hi!

 

I have an issue with distinctcount function:

We have sales table with actual data in January 2017 and January 2018.

For example:

datepoint_keyamount
01.01.2017111200
01.01.2017333100
01.01.2017222300
01.01.2017333400
01.01.2018111100
01.01.2018444400
01.01.2018555200
01.01.2018111300

 

I can take DISTINCTCOUNT of point_keys if I select filter (January 2018) in month = CALCULATE(DISTINCTCOUNT([point_key])) = 3

I can take DISTINCTCOUNT of point_keys in same month of prior year = CALCULATE(DISTINCTCOUNT([point_key]);DATEADD('Calendar'[Date];-1;YEAR)) = 3

 

The matter is how to get increment and decrement in unique point_keys between CY and PY?

in our case we can see that point_key 555 has appeared in January 2018 and point_key 222 has disappeared from January 2017.

 

Well, can I put increment and decrement into different calculated measures?

 

I've tried for increment SUMX(ADDCOLUMNS(mytable;"stream";IF(DISTINCTCOUNT([point_key]) - CALCULATE(DISTINCTCOUNT([point_key]);DATEADD('Calendar'[Date];-1;YEAR))=1;1;BLANK()));[stream])

 

but it sums rows in fact_table 😞

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.