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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
labuser1235
Helper IV
Helper IV

Count holding data on first of calendar year - Day 1

Hi All,

 

I would like the count of that entire year to remember as Day 1 count for that year,and then count should decrease as we sell that item on that particular date. 

 

I have tried DAX measure as: Count(ID) - TOTALYTD(count(ID),datetable(date)) this is completely wrong

However, it doesnt save as Day 1. Which is something I am looking forward to solve.

Any help is appreciated thanks in advance.

 

Input Data:

IDNameDate Sold
456AAA1/10/20
345SSS1/11/20
267BBB1/12/20
128CCC1/13/20
129EEE1/14/20
125FFF1/15/20
567QQQ1/16/20
678GGG12/20/19

 

Output graph expected as: LINK

 
 
 
1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@labuser1235 do you always need a current year?

Table 2 = 
ADDCOLUMNS(
CALENDAR(DATE(YEAR(TODAY()), 1, 1), Max('Input Data Table'[Date Sold])),
"Count Items", CALCULATE(DISTINCTCOUNT('Input Data Table'[ID]), FILTER('Input Data Table', 'Input Data Table'[Date Sold] >= EARLIER([Date]) || ISBLANK('Input Data Table'[Date Sold]) ))
) 

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

7 REPLIES 7
az38
Community Champion
Community Champion

Hi @labuser1235 

create a calculated table

Table 2 = 
ADDCOLUMNS(
CALENDAR(MIN('Input Data Table'[Date Sold]), Max('Input Data Table'[Date Sold])),
"Count Items", CALCULATE(DISTINCTCOUNT('Input Data Table'[ID]), FILTER('Input Data Table', 'Input Data Table'[Date Sold] >= EARLIER([Date])))
) 

 

then put it into chart visual

Снимок.PNG


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

This is almost it...just one thing if there are blanks in date sold its not picking the count exactly.

Can you Just fix this one for me in the dax @az38 

 

az38
Community Champion
Community Champion

@labuser1235 

try

Table 2 = 
ADDCOLUMNS(
CALENDAR(MIN('Input Data Table'[Date Sold]), Max('Input Data Table'[Date Sold])),
"Count Items", CALCULATE(DISTINCTCOUNT('Input Data Table'[ID]), FILTER('Input Data Table', 'Input Data Table'[Date Sold] >= EARLIER([Date]) || ISBLANK('Input Data Table'[Date Sold]) ))
) 

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

This is giving us the count for both the years. It should give me the count specific to each year.

In the example given I have provided 2019 and 2020 data which is counting in 2020 and making it as 8. However, as per that specific year count should change. 

IS that in the filter condition are we suppose to give anything where it identifies the year and change its count.

 

Please help me with this we are almost there @az38 

az38
Community Champion
Community Champion

@labuser1235 

maybe you need this?

Снимок.PNG


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

I get that in visual changes, 

 

However I am clubbing it with other things, so if i can have that specifically within the dax as count year wise it would of great help that is why I am requsesting in it. I am trying to make a filter on calculate after the count but it just doesn't take dynamically. Please help me with this @az38 

az38
Community Champion
Community Champion

@labuser1235 do you always need a current year?

Table 2 = 
ADDCOLUMNS(
CALENDAR(DATE(YEAR(TODAY()), 1, 1), Max('Input Data Table'[Date Sold])),
"Count Items", CALCULATE(DISTINCTCOUNT('Input Data Table'[ID]), FILTER('Input Data Table', 'Input Data Table'[Date Sold] >= EARLIER([Date]) || ISBLANK('Input Data Table'[Date Sold]) ))
) 

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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