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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ishwariya11195
Frequent Visitor

Calculated column which gives dynamic results

I have the follwoing table which a fact table but I have reduced the number of columns here. 

The goal is to have the calculated columne "Calculated country name" which does the follwoing:

 

If the number of manufacturers are less than 3 for a selected year in the filter, the column should evlaute the consition for selected year and selected year -1 ,if number of manufactres is less than 3, if yes , "Others", else "Country name".

 

for example, if 2023 is slected, it evaulated the coniditon for 2023 and 2022 , gives the results.

2024 is sleeected, it evaluated for 2024 and 2023.

 

the below formula is working if hardcoded but not when applied selected filters. kindly help

 

PBI Calc Country Name =
VAR MinTotalSellers =
    MINX(
        FILTER(
            'PBI Fact Others',
            'PBI Fact Others'[Country] = EARLIER('PBI Fact Others'[Country]) &&
                    'PBI Fact Others'[Product Category] = EARLIER('PBI Fact Others'[Product Category]) &&
            ('PBI Fact Others'[Year] = 2022 || 'PBI Fact Others'[Year] = 2023)
        ),
        'PBI Fact Others'[Total Sellers]
    )
RETURN
    IF(MinTotalSellers < 3, "Others", 'PBI Fact Others'[Country])

 

CountryProduct nameNo.of.Manufacturers Calculated country name
IndiaTrolley12022Others
MalasyiaFrame22022Others
IndiaTrolley42023Others
MalasyiaFrame42023Others
IndiaTrolley 52024India
MalasyiaFrame62024Malasyia
1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @ishwariya11195  - can you please check the below measure based on selected filter, hope it works.

 

PBI Calc Country Name =
VAR SelectedYear = MAX('Mfyear'[Year])
VAR Previou = SelectedYear - 1

VAR ManufacturersCurrentYear =
    CALCULATE(
        DISTINCTCOUNT('Mfyear'[No.of.Manufacturers]),
        'Mfyear'[Year] = SelectedYear
    )

VAR ManufacturersPreviousYear =
    CALCULATE(
        DISTINCTCOUNT('Mfyear'[No.of.Manufacturers]),
        'Mfyear'[Year] = Previou
    )

VAR ManufacturersTotal = ManufacturersCurrentYear + ManufacturersPreviousYear

RETURN
    IF(ManufacturersTotal < 3, "Others", MAX('Mfyear'[Country]))

rajendraongole1_0-1738310715540.png

 

 

I hope this works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

Hi @ishwariya11195  - can you please check the below measure based on selected filter, hope it works.

 

PBI Calc Country Name =
VAR SelectedYear = MAX('Mfyear'[Year])
VAR Previou = SelectedYear - 1

VAR ManufacturersCurrentYear =
    CALCULATE(
        DISTINCTCOUNT('Mfyear'[No.of.Manufacturers]),
        'Mfyear'[Year] = SelectedYear
    )

VAR ManufacturersPreviousYear =
    CALCULATE(
        DISTINCTCOUNT('Mfyear'[No.of.Manufacturers]),
        'Mfyear'[Year] = Previou
    )

VAR ManufacturersTotal = ManufacturersCurrentYear + ManufacturersPreviousYear

RETURN
    IF(ManufacturersTotal < 3, "Others", MAX('Mfyear'[Country]))

rajendraongole1_0-1738310715540.png

 

 

I hope this works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.