Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hellloooo
I have the following DAX formula that counts the number of rows based where the date ‘MMYYDD’ (in my calendar table) falls between the min and max dates (table1).
Count =
COUNTROWS (
FILTER (
‘Table1',
[MMYYDD] >= ' Table1' [MinDate]
&& [MMYYDD] < ' Table1'[MaxDate]
)
)
Table1 | ||
AccNum | MinDate | MaxDate |
ACC5281 | 31/03/2021 | 31/03/2024 |
ACC5281 | 31/03/2021 | 31/03/2024 |
ACC5281 | 31/03/2021 | 31/03/2024 |
ACC5281 | 31/03/2021 | 31/03/2024 |
ACC5281 | 31/03/2021 | 31/03/2024 |
ACC5255 | 17/01/2023 | 30/11/2023 |
ACC5255 | 17/01/2023 | 30/11/2023 |
ACC5255 | 17/01/2023 | 30/04/2023 |
ACC5255 | 17/01/2023 | 30/04/2023 |
ACC5254 | 17/01/2023 | 29/02/2024 |
ACC5254 | 17/01/2023 | 29/02/2024 |
ACC5254 | 17/01/2023 | 29/02/2024 |
Unfortunately, Table1 includes duplicate account numbers, and this inflates the figures considerably. Is it possible to amend the above formula so it only counts distinct rows from ‘Table1’ where my AccNum is distinct? I am unable to remove duplicates in PowerQuery as my min/max date calculations are created using DAX in ‘Table1’. This is my end output:-
Cal1 | |
MMYYDD | Count |
01/11/2021 | 81201 |
01/12/2021 | 80930 |
01/01/2022 | 80654 |
01/02/2022 | 80344 |
01/03/2022 | 80166 |
01/04/2022 | 79635 |
01/05/2022 | 78999 |
01/06/2022 | 78366 |
01/07/2022 | 77729 |
01/08/2022 | 77210 |
01/09/2022 | 76604 |
01/10/2022 | 75846 |
01/11/2022 | 75394 |
Any help massively appreciated!
CF
Solved! Go to Solution.
VAR __tab = filter(SUMMARIZE('Table1',[column1],...), ...)
RETURN
countrows(__tab)
think that this virtual table is like a pivot so you get 1 line by accnum
Amazing stuff! Thanks again!!
you're welcome 🙂
in the first 25 days challenge of Curbal, there are quite some examples of such virtual tables... good source of learning...
Many thanks marcl1, I really appreciate the response. Creating a VAR virtual table is a completley new concept to me. Do you have any examples of how I would do that? I am just checking that I am following you correctly, would the VAR virtual table condense Table1, providing just unique AccNum's?
VAR __tab = filter(SUMMARIZE('Table1',[column1],...), ...)
RETURN
countrows(__tab)
think that this virtual table is like a pivot so you get 1 line by accnum
Hi,
you can create a VAR virtual table with the function summarize
then you make the countrows on this virtual table...
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
65 | |
63 | |
52 | |
37 | |
36 |
User | Count |
---|---|
82 | |
66 | |
61 | |
46 | |
45 |