The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I have a sales table which contains username and Dateof sale column along with few products column as shown below.
The dateofsale column is truncated to the begining of the month and each user will have only 1 entry for each month as shown below
I am trying to find whether each user is consistent is his sales in the Year 2018, 2019 and 2020, meaning if the user has done sales in each month of the year, he is consistent, else he is not. In the above pic, user 700081, has done sales for each month in the Year 2018 (total month count 12) , hence he is consistent in 2018, but in the year 2019 he has done sales only for 3 months in 2019 and hence he is not consistent in the year 2019, the same user has no sales in 2020, hence he is inconsistent in the Year 2020 as well.
I tried to achieve this is 3 steps.
Step 1 : If a user has done sales in the year 2018, then give the output as 1, else 0. I created a calculated column as shown below
Solved! Go to Solution.
Hi, @Ishaq
You can try the following dax to achieve your need.
Dax:
Year = YEAR([DateofSale])
YearMonth = YEAR([DateofSale]) & "-" & MONTH([DateofSale])
MonthCount =
CALCULATE(
DISTINCTCOUNT(Sales[YearMonth]),
ALLEXCEPT(Sales, Sales[UserName], Sales[Year])
)
ConsistencyCheck =
IF(
MAX(Sales[MonthCount]) = 12,
"Inconsistent",
"Consistent"
)
Best Regards,
Yang
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 in the Power BI Forum
Hi, @Ishaq
You can try the following dax to achieve your need.
Dax:
Year = YEAR([DateofSale])
YearMonth = YEAR([DateofSale]) & "-" & MONTH([DateofSale])
MonthCount =
CALCULATE(
DISTINCTCOUNT(Sales[YearMonth]),
ALLEXCEPT(Sales, Sales[UserName], Sales[Year])
)
ConsistencyCheck =
IF(
MAX(Sales[MonthCount]) = 12,
"Inconsistent",
"Consistent"
)
Best Regards,
Yang
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 in the Power BI Forum
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |