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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cris1196
Helper I
Helper I

Count how many values of one variable are in another variable

Hello everyone. I have this table

(https://docs.google.com/spreadsheets/d/11g-BxXQ-AjcXMVl2h_Yji3bk63BqKxLw/edit?usp=sharing&ouid=10668...)

 

and I want to create something similar to this

 

The only way I could think of to do this is:

Measure =
var SelectedMonth = selectedvalue(T1[YearMonth])
var AllUserMonth= All users who bought in SelectedMonth , filtered by first_order = True

//Then:
Var Day01= All users who bought on day one (Daydate=1), filtered by SelectedMonth
Var Day02= All users who bought on day two (Daydate=2), filtered by SelectedMonth
Var Day03= All users who bought on day three, filtered by SelectedMonth

etc.... untill

Var Day31= All users who bought on day 31, filtered by SelectedMonth

//So, here at the end, make a Count of  "how many Day01 users there are in AllUserMonth"; "how many Day02 users there are in AllUserMonth"..... etc untill Day31.

 

So, I need a way to calculate "how many values of one variable are in this other variable". I tried several ways with addcolumns but no success. 

I know this is inefficient, that if the SelectMonth doesn't work I'll have to create a variable for each month and then day variables for each month... but I have no problem writing all that (And it's the only way I could think of that could replicate the Excel table in PBI 😣)

 

 

Any help is welcome, thanks 🙂

 

1 REPLY 1
Anonymous
Not applicable

@cris1196

 

You can get the required date like this:

VAR _CUR_DATE = MAX('T1'[ORDER_DATE])
VAR _DATE_MIN = DATE(YEAR(_CUR_DATE),MONTH(_CUR_DATE),DAY(_CUR_DATE))
VAR _DATE_MAX = DATE(YEAR(_CUR_DATE),MONTH(_CUR_DATE),DAY(_CUR_DATE))+1

Please feel free to let me know if I misunderstood your needs. It would be helpful if you could attach the measure you created for each day below.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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