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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Shliim_1
Frequent Visitor

Filter upon a calculated column or build a calculated column on a calculated column.

Hi, 

 

I have a large table that looks something like this: 

 

Latest_record_countNumber_of_columns_filledclientIDas_of_datedata_about_client
3231  
4221  
1222  
2222  
2223  
3233  

 

The column "Latest_record_count" returns the most recent row and the column. "Number_of_columns_filled" gives me the most complete dataset (the higher the value, the more recent the data).

 

A lot of preprocessing is done in Python, but further preprocessing is out of the question due to the need to keep track of historical occurrences.

 

I need Power BI to return, for every ID, the row with the maximum number of rows filled. Then, based on that, I can filter the dataset to find the maximum value that occurs within this filtered dataset.

It's possible for the maximum value in "Latest_record_count" to be lower than the absolute maximum value of the latest record count.

I want to obtain a table that shows the following:

 

Latest_record_count   Number_of_columns_filled  clientID  as_of_date  data_about_client
3 231  
4 221  
1 222  
2 222  
2 223  
3 233  

 

Whenever I do these steps manually in excel and compare this in a table generated in PowerBI I get totally different results. 

this because I cant get PowerBI filter upon an already filtered datatable.  Moreover this in total needs to function as a filter and not as a table. 

 

I eventually want to calculate multiple things like: distintcounts, averages etc based on this filter where there will be a visual that even more cuts into the data with the as_of_date column (BTW the as_of_data is in principle the same as Latest_record_count) but for certain calculations it makes it way easier to use integers. 

 

hopefully someone could help me. 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@Hi @Shliim_1 

Please refer to attached sample file for the proposed solution

1.png

FilterMeasure = 
COUNTROWS (
    FILTER ( 
        'Table',
        MAXX (
            TOPN ( 
                1,
                CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[clientID] ) ),
                'Table'[Number_of_columns_filled]
            ),
            'Table'[Latest_record_count]
        ) = 'Table'[Latest_record_count]
    )
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

@Hi @Shliim_1 

Please refer to attached sample file for the proposed solution

1.png

FilterMeasure = 
COUNTROWS (
    FILTER ( 
        'Table',
        MAXX (
            TOPN ( 
                1,
                CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[clientID] ) ),
                'Table'[Number_of_columns_filled]
            ),
            'Table'[Latest_record_count]
        ) = 'Table'[Latest_record_count]
    )
)

Thx!!! works like a charm 😃

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.