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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Help getting a count with filters

I think its a very simple solution but I can't get the answer 

IDDescriptionDate
CSProgrammed2/2/2023
CSPurchase2/2/2023
CSProgrammed3/10/2023
CSProgrammed5/9/2023
CSPurchase4/14/2023
CJProgrammed1/30/2023
CJPurchase1/30/2023
CJProgrammed6/9/2023
CJPurchase5/19/2023
CIPurchase5/19/2023
CIPurchase6/20/2023
CIProgrammed4/28/2023
CIProgrammed6/21/2023

I want to count the amount of purchase that were made in the same day of the programmed by ID and then divide by another measure

This is what I have for now but I think I'm overcomplicating 

% of compliance =
CALCULATE(
    COUNTX(
    ADDCOLUMNS(
        CALCULATETABLE(
            SUMMARIZE(Data, Data[ID], Data[Date]),
            Data[Description] = "Purchase"
        ),
        "@same",
            var _dt = Data[Date]
            return
                CALCULATETABLE(
                    VALUES(Data[Date]),
                    REMOVEFILTERS(Data[Date]),
                    Combinar2[Evento] = "Programmed"),
    [@same]
))/[Amount of weeks programmed to today])
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@amitchandak 

Helped me with this solution

You have to create 2 measures.

The first one would be to create a measure filtering by Programmed

Programmed = COUNTROWS(FILTER(Data, Data[Description] = "Programmed"))

then create another measure that counts the days that are the same

On Same Date = 
COUNTROWS(FILTER(Data, not(ISBLANK([Programmed])) && not(ISBLANK(countx(filter(all(data), Data[ID] = EARLIER(Data[ID]) && Data[Date] = EARLIER(Data[Date]) && Data[Description] = "Purchase"), Data[ID])))))

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I followed everything, just changed 

Data[Evento] = "Programmed"

to 

Data[Description] = "Programmed"

because it's in the same column but I receive this error message.

A single value for column 'Evento' in table 'Data completa' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

Anonymous
Not applicable

@amitchandak 

Helped me with this solution

You have to create 2 measures.

The first one would be to create a measure filtering by Programmed

Programmed = COUNTROWS(FILTER(Data, Data[Description] = "Programmed"))

then create another measure that counts the days that are the same

On Same Date = 
COUNTROWS(FILTER(Data, not(ISBLANK([Programmed])) && not(ISBLANK(countx(filter(all(data), Data[ID] = EARLIER(Data[ID]) && Data[Date] = EARLIER(Data[Date]) && Data[Description] = "Purchase"), Data[ID])))))

 

Anonymous
Not applicable

Hi @Anonymous ,

 

Try it:

 

% of compliance =
VAR _ProgrammedDates =
    FILTER(
        VALUES(Data[Date]),
        Data[Evento] = "Programmed"
    )
RETURN
    DIVIDE(
        COUNTX(
            FILTER(
                ALL(Data),
                Data[Description] = "Purchase"
                    && Data[Date] IN _ProgrammedDates
            ),
            Data[ID]
        ),
        [Amount of weeks programmed to today]
    )

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.