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
Nowhitescreens
Regular Visitor

Count distinct values AND Filter by Calendar (AND maybe Summarize them)?

Sorry for the prntScrn pics, but I cant paste with ctrl+V (worked fine earlier this week).

PowerBI 1.pngPowerBI 2.png



 
 

 

2 REPLIES 2
selimovd
Super User
Super User

Hey @Nowhitescreens ,

 

I can answer your first question:

DISTINCTCOUNT: returns the count of distinct values. For example when customer 1111 is buy 3 times a product, DISTINCTCOUNT will return 1 as it counts the distinct values.

 

COUNTROWS: returns the count of rows. For example when customer 1111 is buy 3 times a product, COUNTROWS will return 3 as the table contains 3 rows.

 

SUMMARIZE: is a table function. It will return a table that is summarizing the distinct values in the columns you mention as parameter. Here an example from Analytics Insights Ninja:selimovd_1-1622456946577.png

 

Check the whole article:

 Creating Summary Tables Using DAX SUMMARIZE() Function in Power BI – Analytics Insights Ninja (wordp...

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Sorry for the late reply. Got help from a PBI consultant at work.

The solution comes in 3 steps:
1) Create column, distinctcount nr of accounts per person at that time
2) Create column that compare above with all previous dates 
3 Create  column that specifies "Yes" if nr of accounts have changed per row
Pasting the DAX below. Sorry for not translating it to english, but I trust you get the point.  

1)
#Antal konton vid transaktionen =

var _personnummer = 'TABELL'[PERS_NR]

var _BESLDATUM = TABELL[BESLDATUM]

return

CALCULATE(

    DISTINCTCOUNTNOBLANK(

        TABELL[KONTONUMMER]),

        FILTER(

            ALL(

                TABELL),

                TABELL[PERS_NR] = _personnummer

                && TABELL[BESLDATUM] <= _datum)

)

 

2)

#Antal konton vid tidigare transaktioner =

var _personnummer = 'TABELL'[PERS_NR]

var _BESLDATUM = TABELL[BESLDATUM]

return

CALCULATE(

    DISTINCTCOUNTNOBLANK(

        TABELL[KONTONUMMER]),

        FILTER(

            ALL(

                TABELL),

                TABELL[PERS_NR] = _personnummer

                && TABELL[BESLDATUM] <= _datum-1)

)

 

 

3)
#Nytt konto registrerat under månaden =

if(

    TABELL[Antal konton vid transaktionen]-TABELL[Antal konton vid tidigare transaktioner]<>0, "Ja", "Nej")





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.

Top Solution Authors