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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ST
Frequent Visitor

Count ID's, in each month, that verify a condifition

Hi everyone!

 

I'm trying to build a measure that counts ID's of an element that meet a certain criteria by month and by the total of the year.

The measure i got at this point is this one:

 

Total IDs = 
CALCULATE (
    DISTINCTCOUNT ( facViagensPermanentes[t_motr] ),
    FILTER (
        VALUES ( facViagensPermanentes[t_motr] ),
        facViagensPermanentes[Total de Km's]
                        >= [Km's Contr.]
                        * ( 1
                        - [Tolerância de Produtividade Value] / 100 )
    )
)

 

This measure is working OK on the month granularity, but in the total Year granularity this measure is counting all ID's, for some reason, and so its wrong on this last granularity level.
How would one change this measure, in order to count, in the year granularity, the number of ID's that meet this criteria:

 

facViagensPermanentes[Total de Km's]
                        >= [Km's Contr.]
                        * ( 1
                        - [Tolerância de Produtividade Value] / 100 )

and maintain, at the month granularity, the same results given by the measure [Total IDs] that i indicated before ?

 

 

 

Also [Total de Km's] is a measure calculated this way:

Total de Km's = SUM( facViagensPermanentes[t_kvzcr] ) + SUM( facViagensPermanentes[t_kmcr] )

 and [Km's Contr.] is another measure, calculated this way:

[Km's Contr.] = 
IF( HASONEFILTER( facViagensPermanentes[Fornecedor] ) && HASONEFILTER( facViagensPermanentes[Rota] ),
    BLANK(),
IF (    
        AND (
            HASONEFILTER ( dimdate[Mes] ),
            HASONEFILTER ( facViagensPermanentes[t_motr] )
        )
    ,
    LOOKUPVALUE (
        dimservico[Kms],
        dimservico[t_serv], (
            LOOKUPVALUE (
                dimVeiculos[t_serv],
                dimVeiculos[t_motr], FIRSTNONBLANK ( facViagensPermanentes[t_motr], TRUE () )
            )
        )
    ),
    BLANK ()
)
)

 

 

If need more info pls let me know.

Thanks in advance.  🙂

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @ST,

 

It's hard to imagine your scenario with current description. It would be better you could illustrate requirement with sample data (table structure and detailed data) and show us your desired output.

How to Get Your Question Answered Quickly

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi everyone!

 

@v-yulgu-msft, I shared a link to an example PBI file regarding this issue: Problem Example

Model Structure:

Model Structure .PNG

Tables Structure:
dimDates Structure.PNGdimVehicles Structure.PNGfacServices Structure.PNGfacTrip Structure.PNGTolerancia Produtividade Structure.PNG

 

Please let me know if u want any more info.

Thank is advance for your help.

 

🙂

ST
Frequent Visitor

Can someone shed some light on me ?

I'm struggling with this problem since i posted here this morning 😞

 

Thanks.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.