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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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