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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
mafaber
Helper II
Helper II

Search within specific month

Hi,

 

I have a table with 4 columns, 'kpi', 'month', 'status' and 'value'. Status is either 'final' or 'preliminary'. I'd like to create a month_status column that returns 'final' if all the rows for the specific month are 'final', or 'prelim', if there is at least 1 row that has 'prelim' in column 'status'.

I tried modifying somehow below formula, but I could not make it do the search within a specific month only.

month_status =
if(
iserror(
search("prelim",
Table[status])
)
),
"final",
"prelim"
)
1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

This could/should be done as a measure probably, but here is a column expression that should work.  Not sure if you are checking all KPIs within the month or within a given KPI for that month, but both variations shown.

 

month_status =
VAR vPrelimRows =
    CALCULATE (
        COUNTROWS ( table ),
        ALLEXCEPT (
            table,
            table[Month]
        ),
        table[Status] = "Preliminary"
    )
RETURN
    IF (
        ISBLANK ( vPrelimRows ),
        "Final",
        "Preliminary"
    )

 

replace Table with your actual table name.  If you are looking within a KPI and month use

ALLEXCEPT(Table, Table[Month], Table[KPI])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

This could/should be done as a measure probably, but here is a column expression that should work.  Not sure if you are checking all KPIs within the month or within a given KPI for that month, but both variations shown.

 

month_status =
VAR vPrelimRows =
    CALCULATE (
        COUNTROWS ( table ),
        ALLEXCEPT (
            table,
            table[Month]
        ),
        table[Status] = "Preliminary"
    )
RETURN
    IF (
        ISBLANK ( vPrelimRows ),
        "Final",
        "Preliminary"
    )

 

replace Table with your actual table name.  If you are looking within a KPI and month use

ALLEXCEPT(Table, Table[Month], Table[KPI])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


It works, thank you!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.