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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
kb4514
Frequent Visitor

Count a frequency measure

I have a measure which counts the number of transactions per id within a timeframe (from slicer):
 
mFrequency = IF(DISTINCTCOUNT(RPT_FACTORDER[TRANSACTION_NUMBER]) = BLANK(), 0,
                        IF(DISTINCTCOUNT(RPT_FACTORDER[TRANSACTION_NUMBER]) = 1, 1,
                        IF(DISTINCTCOUNT(RPT_FACTORDER[TRANSACTION_NUMBER]) = 2, 2,
                        IF(DISTINCTCOUNT(RPT_FACTORDER[TRANSACTION_NUMBER]) = 3, 3, 4))))
 
Which gets me output like this:
 
Id       mFrequency
111    1
222    1
333    3
444    2

555    1
 
Now I need to count up the measure (mFrequency) to get results which look like this, and change based on the slicer timeframe:
 
mFrequency Count
1                    3
2                    1
3                    1
4                    0
 
I'm new to Power BI.  Help is appreciated.  Thanks.

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi,

 

since you need frequency on the axis, you need to add a stand-alone table with the neccessary values. And based on those values, count the number of IDs with corresponding frequency.

This measure would look like this

Measure =
VAR _count =
    COUNTROWS (
        FILTER (
            ADDCOLUMNS (
                VALUES ( 'Table'[id] );
                "@freq";
                VAR _trans =
                    CALCULATE ( SUM ( 'Table'[transactions] ) )
                RETURN
                    IF ( _trans > 3; 4; _trans )
            );
            [@freq] = SELECTEDVALUE ( Frequency[F] )
        )
    )
RETURN
    IF ( ISBLANK ( _count ); 0; _count )

Since you have not provided any data or sample report, I have created a mockup dataset and created a demo report based on that dataset: pbix

cheers,

S

View solution in original post

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi,

 

since you need frequency on the axis, you need to add a stand-alone table with the neccessary values. And based on those values, count the number of IDs with corresponding frequency.

This measure would look like this

Measure =
VAR _count =
    COUNTROWS (
        FILTER (
            ADDCOLUMNS (
                VALUES ( 'Table'[id] );
                "@freq";
                VAR _trans =
                    CALCULATE ( SUM ( 'Table'[transactions] ) )
                RETURN
                    IF ( _trans > 3; 4; _trans )
            );
            [@freq] = SELECTEDVALUE ( Frequency[F] )
        )
    )
RETURN
    IF ( ISBLANK ( _count ); 0; _count )

Since you have not provided any data or sample report, I have created a mockup dataset and created a demo report based on that dataset: pbix

cheers,

S

Thanks so much!  It worked perfectly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.