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
Anonymous
Not applicable

Capture date when a flag is updated only

Hi.

 

I have three columns in a table; created_at, updated_at and flag. When a user gets created, both created_at and updated_at are the same value. The flag can be either 0 or 1; 0 if the user is a guest user and 1 if they are registered. A guest can later register and this flag is updated from 0 to 1. When they register, the updated_at is also updated to the date the user registers. 

 

Problem is, the updated_at property not only updates when a guest converts to a registered user, but also when the user edits anything in their profile. It's basically the property to show the user 'record' was modified somehow.

 

What I want is a measure/calculated column that captures the updated_at date ONLY as soon as the flag changes from 0 to 1; when the updated_at updates again, I don't want the new measure to have that. How would I do that?

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If you have all change history/log in data source table, we can consider using the date of the first flag '1' as the registered date for a registered user.  

 

If you only have latest updated data in data source table, we can not capture the registered date with Power BI. In Power BI, every refresh is a full refresh which reimports data from data sources and do transformations & calculations on these new data again. We cannot store a historical calcualtion result in the model. In this case, you would better consider adding a "registered_at" column in the data source table. This column captures a date when a user's flag turns from 0 to 1 to store his registered date and won't change later. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

5 REPLIES 5
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If you have all change history/log in data source table, we can consider using the date of the first flag '1' as the registered date for a registered user.  

 

If you only have latest updated data in data source table, we can not capture the registered date with Power BI. In Power BI, every refresh is a full refresh which reimports data from data sources and do transformations & calculations on these new data again. We cannot store a historical calcualtion result in the model. In this case, you would better consider adding a "registered_at" column in the data source table. This column captures a date when a user's flag turns from 0 to 1 to store his registered date and won't change later. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

parry2k
Super User
Super User

@Anonymous you cannot do that until you have a history/log of all the changes and also that history identifies what is changed. if the updated_at changes when any value in the record is changed, and there is no history/log, nothing can be done. You need to store the changes at the backend first (in your database) and then you can show updated_at for that specific use case. it is more of a backend data issue rather than power bi stuff.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hate to bump threads, but any help would be appreciated on this. Curently blocking a lot of progress from my side. 

amitchandak
Super User
Super User

@Anonymous , when do want this to happen, at the time of data load?

Or do you have a record of the user for each date with a flag ?

 

 

Anonymous
Not applicable

I have the Power BI in scheduled refresh, so every time the data is refreshed. 

 

The flag exists for all users; if it's 1 from the start, it means he registered immeditately, if it's 0 it means the user is in guest mode. Guest users who converted to registered users (flag 0 to 1) will have the new measure/column as a date while the users who already registered from the start will have it as null. 

 

Table looks something like this:

 

user_idcreated_atupdated_atflag
120/10/202120/10/20211
220/12/2021null0

 

Note again that the updated_at also updates when the user edits their info. 

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.