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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

DAX function for filtering in a peculiar way

Let's see if I can make this message clear 😉

I have a set of data, that contains User IDs and their purchasing date. I want to know how many distinct users were active (had transactions) during a month. This is easy as I just use DISTINCTCOUNT(), and get the desired result. The problem arises, when I want to filter out said users. I want to select a month to the count of the distinct users during that month AND how many of them were active during the whole observation period. For example , i want to select people that were making a purchase during the January of 2018, and then see how many of said people were active during other months. The problem is, that I need to do this using DAX functions, not querry or external data manipulation tools. ive tryed several different things, but can not seem to come to an answer. I am not a very experienced power BI user, but this is one of my latest attempts (though unsuccsesful): 

 

Activity_users =
VAR User = DISTINCT('Papildomi pavyzdiniai duomenys Andriui'[UserId])
VAR test = "2014-01"
VAR active = IF(VALUES('Papildomi pavyzdiniai duomenys Andriui'[TransActionYM]) = test, 1 , BLANK())
VAR Grouped = SUMMARIZE('Papildomi pavyzdiniai duomenys Andriui','Papildomi pavyzdiniai duomenys Andriui'[UserId],"useriai", active)
--VAR ifactive = IF(active=1, DISTINCT('Papildomi pavyzdiniai duomenys Andriui'[UserId]),BLANK())
--VAR final = CALCULATE(DISTINCTCOUNT('Papildomi pavyzdiniai duomenys Andriui'[UserId]),active>0)
RETURN
COUNTX(Grouped,active)
 



commented lines are other attempts to this problem.

1 ACCEPTED SOLUTION
Anonymous
Not applicable
4 REPLIES 4
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Could you please share more information sbout your "I want to select a month to the count of the distinct users during that month AND how many of them were active during the whole observation period", you can share some sample data and expected result to us for analysis.

Best Regards,

Teige

Anonymous
Not applicable

Transaction_year_monthUser
2011-01Bob
2011-02Bob
2011-03Bob
2011-04Bob
2011-05Bob
2011-06Bob
2011-07Bob
2011-08Bob
2011-09Bob
2011-10Bob
2011-11Bob
2011-12Bob
2011-02Adam
2011-03Adam
2011-04Adam
2011-06Joe
2011-07Joe
2011-08Joe
2011-01Victor
2011-05Victor
2011-09Victor
2011-01Peter
2011-02Peter
2011-01Carl
2011-02Carl
2011-03Carl
2011-04Carl
2011-05Carl
2011-06Carl
2011-07Carl
2011-08Carl
2011-05Stewart
2011-06Stewart
2011-07Stewart
2011-08Stewart
2011-09Stewart
2011-10Stewart
2011-11Stewart
2011-12 

 Thank you for your response, I can not share the actual data, but I am including some simplified mock data. The idea would be, that if I selected one of the dates, let us say 2011-05, i need to see all people that had transactions that day as well as what other months they were active. The graph should includea spike on selected month and some data points trhoughoutthe whole period. My actual data is agregated to days rather then months as well. Thank you for your help!

Hi @Anonymous ,

It's sorry that, based on my test, it looks like that we can't meet this requirement using DAX query.

Best Regards,

Teige

Anonymous
Not applicable

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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