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
Nazeer_at_ADS
Frequent Visitor

Count # of Fields used <=5 times

Hi There,

 

I'm very new to Power-BI and I need some help with DAX formula.

 

Scnario:

I have two columns with Field Name and Session ID. I want the distinct Fields count which are used less then equal to 5 times (using Session ID). I was able to create below table where we can see the Field Names and Distinct Count of Session.

 

Data Sample:

 

Field NameCount of Session ID (Distinct)
Fiscal Year1
Fiscal Quarter1
Service Indicator2
Product3
Country5
Architectures5
Geo7
Segments9
Total Billed11
Revenue Flag15

 

Expected Result:

Fields Used <= 5 Times: 6

 

Please can you help me with it.

 

Many Thanks

Nazeer

5 REPLIES 5
harshnathani
Community Champion
Community Champion

Hi @Nazeer_at_ADS ,

 

 

Try this measure

 

Fields less than 5eq times = 
var dc = CALCULATE(DISTINCTCOUNT('Table'[Field Name]),'Table'[Count of Session ID (Distinct)] <=5)
RETURN
dc

 

 

1.jpg

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

amitchandak
Super User
Super User

@Nazeer_at_ADS , Try like

countx(values(Table[Field Name]),if([Count of Session ID (Distinct)]<5,Table[Field Name],blank()))

mahoneypat
Employee
Employee

Please try this measure expression

 

Fields Used <6 times =
COUNTROWS (
    FILTER (
        VALUES ( Table[Field Name] ),
        CALCULATE ( DISTINCTCOUNT ( Table[SessionID] ) ) <= 5
    )
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lbendlin
Super User
Super User

use countrows() with a filtered table.

 

something like 

 

Countrows(filter(table,table[Count of Session ID (Distinct)]<6))

Thanks Ibendlin for your reply. 

I'm not getting the desired output. I want the count of Field Name's which are used less than 6 times. 

 

If you look at the below, it says Fiscal Year and Fiscal Quarter were used only once (based on Session ID Count). Service Indicator was used twice and Product 3 times. Now based on the Session ID count for each Field Name I want to count distinct Field Names which were used less <=5 times or <6 times.  

 

The result from below table should be: 4 Fields

 

Sample Data:

Field NameSession ID
Fiscal Year101
Fiscal Quarter101
Service Indicator101
Service Indicator102
Product101
Product102
Product103

 

-Nazeer

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.