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
JGRA
New Member

Calculate number of filled-in fields of latest record per month (for n-month period) needed

Hi all,
I'm a newbe on the forum. I hope my question is at the right place and you're able to help me.

My issue: I've a database containing a table with productrecords. If a product is added, a new record is created with a number of fields, among with a statusfield 'A' and a timestamp field. After making a change to one of the fields, the current record is changed to status 'U' and a new record is created with status 'A', containing the actual (new) data. The 'U' status records are historical records.
To see the actual records, I can select all 'A' status records or just all distinct productrecords with the newest timestamp.
I want to have a report on the filled-status of some of the fields in this table per month over the last 12 month. There can be multiple updates in a month on a record. I've to have the latest value for each productrecord in a month to count. If in a particular month no changes are made, the latest records in the month before are valid and need to be counted.

 

My question: how can I create a report table (as below) to have a count on the filled status of fields at the end of each month over the last n-month?


Example table:

IdproducttimestampFieldvalue1Fieldvalue2Status
1Prod-112-03-2018 23:59  U
3Prod-202-04-2018 08:32Value 1 U
5Prod-315-04-2018 09:02  U
2Prod-125-04-2018 13:00Value 2 U
4Prod-226-05-2018 09:15Value 3Value 4U
6Prod-326-05-2018 10:00Value 5 A
8Prod-126-05-2018 14:15Value 2Value 6U
10Prod-227-05-2018 11:11Value 3Value 4A
12Prod-101-06-2018 10:00Value 2Value 7A

Results in report:

Report:    
 month-3month-2month-1current month
 (march)(april)(may)(june)
Total products1333
Fieldvalue10233
Fieldvalue20033

 

I hope I made myself clear about the issue and my expectations. Otherwise, let me know...

 

Thanks for your help.

Kind regards,

Johan

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi JGRA,

 

To achieve your requirement, create three measures using DAX formula like this:

Total products = CALCULATE(DISTINCTCOUNT(Table1[product]), ALLEXCEPT(Table1, Table1[Month]))

Count of Fieldvalue1 = CALCULATE(DISTINCTCOUNT(Table1[Fieldvalue1]), ALLEXCEPT(Table1, Table1[Month]), Table1[Fieldvalue1] <> BLANK())

Count of Fieldvalue2 = CALCULATE(DISTINCTCOUNT(Table1[Fieldvalue2]), ALLEXCEPT(Table1, Table1[Month]), Table1[Fieldvalue2] <> BLANK())

捕获.PNG

PBIX: https://www.dropbox.com/s/cktiqmrx4cjx1p7/Calculate%20number%20of%20filled-in%20fields%20of%20latest...

 

Regards,

Jimmy Tao

View solution in original post

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

Hi JGRA,

 

To achieve your requirement, create three measures using DAX formula like this:

Total products = CALCULATE(DISTINCTCOUNT(Table1[product]), ALLEXCEPT(Table1, Table1[Month]))

Count of Fieldvalue1 = CALCULATE(DISTINCTCOUNT(Table1[Fieldvalue1]), ALLEXCEPT(Table1, Table1[Month]), Table1[Fieldvalue1] <> BLANK())

Count of Fieldvalue2 = CALCULATE(DISTINCTCOUNT(Table1[Fieldvalue2]), ALLEXCEPT(Table1, Table1[Month]), Table1[Fieldvalue2] <> BLANK())

捕获.PNG

PBIX: https://www.dropbox.com/s/cktiqmrx4cjx1p7/Calculate%20number%20of%20filled-in%20fields%20of%20latest...

 

Regards,

Jimmy Tao

Thnkx for your response Jimmy. I will try this out.

 

Kind regards,

Johan

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.