March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all
I'm quite new to Power BI and currently stuck with row count based on slicer value.
I have Document table with main columns: CustomerID, Date Made and Date Finalised.
Date table was added as:
On my page I have date range Slicer based on Date Finalised Table and Table visual.
I'd like to show finalised and not finalised document count:
Finalised: Date Finalised is not empty and is between Slicer range
Not Finalised: Date Finalised is empty or Date Finalised is later than Slicer max date.
In Table visual I'd like to see something like:
Docs Finalised 35
Docs Not Finalised 27
External filters will be applied to Document as well.
Please help
Regards
Solved! Go to Solution.
Hi @Ksm2004,
Here is my solution:
Finalised = COUNT(Document[Date Finalised])
Not Finalised =
VAR _MaxDate = MAX('Date Finalised Table'[Date] )
VAR _AfterMaxDate=
CALCULATE(
[Finalised],
FILTER(
ALL(Document),
Document[Date Finalised] >_MaxDate
)
)
VAR _BlankDate =
CALCULATE( COUNTBLANK(Document[Date Finalised]), ALL(Document))
VAR _Result = _AfterMaxDate + _BlankDate
RETURN
_Result
Final output:
Proud to be a Super User!
Please find a sample file:
https://drive.google.com/file/d/1Ei8dW8aCG7pyMN1NZA7I-y9dY5y232CG/view?usp=sharing
With Slicer range set 1-30/03/2024 and data as:
result should be:
Finalised: 4
Not Finaalised: 6
Thanks
Hi @Ksm2004,
Here is my solution:
Finalised = COUNT(Document[Date Finalised])
Not Finalised =
VAR _MaxDate = MAX('Date Finalised Table'[Date] )
VAR _AfterMaxDate=
CALCULATE(
[Finalised],
FILTER(
ALL(Document),
Document[Date Finalised] >_MaxDate
)
)
VAR _BlankDate =
CALCULATE( COUNTBLANK(Document[Date Finalised]), ALL(Document))
VAR _Result = _AfterMaxDate + _BlankDate
RETURN
_Result
Final output:
Proud to be a Super User!
Thanks a lot! Works as expected.
Could you give some comments on the code please.
@Ksm2004
See if this comments can help you to understand the logic I'm using:
Not Finalised =
VAR _MaxDate = MAX('Date Finalised Table'[Date] ) -- Find the Max Date of the context
VAR _AfterMaxDate=
CALCULATE(
[Finalised], -- Same as COUNT(Document[Date Finalised])
FILTER(
ALL(Document), -- Remove all filter on this table
Document[Date Finalised] >_MaxDate -- Give me only the rows where date finalised is bigger than the max date of the slicer
)
)
VAR _BlankDate =
CALCULATE( COUNTBLANK(Document[Date Finalised]), ALL(Document)) -- count all blank rows of the column "Date Finalised" and do this calculation of all rows of the document table (I'm using again ALL function to remove any filter)
VAR _Result = _AfterMaxDate + _BlankDate
RETURN
_Result
Proud to be a Super User!
Thanks for the explanation!
I'm trying to transfer measures to a real project. It's using dataverse as a backend and Direct Query model.
If I try to slide the Slicer, all values (Finalised and Not Finalised ) becomes blank.
Any advice on how to address it please.
Hi @Ksm2004,
Can you please provide a sample of your data, for example two table with some data, and the final output?
Proud to be a Super User!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |