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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Shree_185
Helper I
Helper I

DAX Calculated Column Help

Hi Everyone, 

 

Trying to replicate the below view in one line query (calculated column)

 

Calculate column = Region-wise Distinct Count ID  WHERE Date is not blank OR Date is not equal to 01/01/2000

 

 

Shree_185_0-1661884056645.png

Sample data :

Shree_185_1-1661884290988.png

To copy-paste sample data in Excel

RegionIDDate
CGCS001934-A-0011/1/2000
CGCS001935-A-0013/29/2021
CGCS002020-A-00210/18/2021
CGCS002027-A-0029/1/2021
CGCS002033-A-0029/21/2021
CGCS002034-A-0021/1/2000
CTXS000709-A-001 
CTXS001129-A-0016/3/2021
CTXS001136-A-0023/9/2022
CTXS001140-A-0016/22/2022
OPWS000761-A-0011/1/2000
OPWS000773-A-001 
OPWS000775-A-0018/17/2021
OPWS000784-A-0018/27/2021
OPWS000830-A-0017/23/2022
1 ACCEPTED SOLUTION

If you need the visual you posted, it should work. If you need it in a table visual, you need to add an ALLEXCEPT function in the filter expression:

Count ID ALLEXCEPT =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Region] ),
        NOT ( ISBLANK ( 'Table'[Date] ) )
            && 'Table'[Date] <> DATE ( 2000, 1, 1 )
    )
)

result.png

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

Try:

Count ID =
CALCULATE(DISTINCTCOUNT(Table[ID), FILTER(Table, NOT(ISBLANK(Table[Date])) && Table[Date] <> DATE(2000, 1, 1)))





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown Thanks for your help. The logic didn't work? or maybe I did some mistake. can you please send me the PBIX file if possible?

If you need the visual you posted, it should work. If you need it in a table visual, you need to add an ALLEXCEPT function in the filter expression:

Count ID ALLEXCEPT =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Region] ),
        NOT ( ISBLANK ( 'Table'[Date] ) )
            && 'Table'[Date] <> DATE ( 2000, 1, 1 )
    )
)

result.png

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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