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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

calculation of new records per status

hi all,

 

i've been facing a while in the following calculation.

I have a table which contains for each store the status (open, closed or opening -it's before the opening), and the date of check.

 

Now: i'd like to calculate the followings:

  • a chart which shows the trend -let's say per month- of the new open stores (and closed). Only the new/closed, separately. I'm not interested in how many stores are open, here the focus is how many in a month have been opened.
  • from the chart, i should be able to click on the element and to view in the table the details. Ie. i click on the new open stores in March, and in the table I view the stores. (not all the "open" stores, but only the new opens).

below the link with a sample

https://drive.google.com/file/d/1B68eDEGq0Gr3Z46ozuFxm-4dgX_riSiO/view?usp=sharing

 

do you think is it something feasible with power bi?

thanks in advance, and for further details please do not hesitate!

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You mean we just need to consider the [date] and the [status]. If so, try this one, please.

ifNewOpen =
VAR existedStores =
    CALCULATETABLE (
        VALUES ( store_progress[store] ),
        FILTER (
            ALL ( 'store_progress' ),
            'store_progress'[date] <= EOMONTH ( EARLIER ( [date] ), -1 )
                && store_progress[status] = "open"
        )
    )
RETURN
    IF ( [store] IN existedStores || NOT [status] = "open", "No", "Yes" )

calculation-of-new-records-per-status2

 

Best Regards,

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

adding:

  • i can calculate the number of the new store opened/closed in the last month by creating an automatic table, but i need to have for all the months
  • dimensions like "date of open" and "date of close" are not available/consistent

Hi @Anonymous,

 

Please download the demo from the attachment. 

Since you'd like to filter them in the visual, I think we need a calculated column.

ifNewOpen =
VAR existedStores =
    CALCULATETABLE (
        VALUES ( store_progress[store] ),
        FILTER (
            ALL ( 'store_progress' ),
            'store_progress'[date] <= EOMONTH ( EARLIER ( [date] ), -1 )
        )
    )
RETURN
    IF ( [store] IN existedStores, "No", "Yes" )

Then count the [ifNewOpen] directly or create a measure.

Measure =
VAR existedStores =
    CALCULATETABLE (
        VALUES ( store_progress[store] ),
        FILTER (
            ALL ( 'Calendar'[Date] ),
            'Calendar'[Date] <= EOMONTH ( MIN ( 'Calendar'[Date] ), -1 )
        )
    )
RETURN
    CALCULATE (
        COUNT ( store_progress[store] ),
        FILTER ( ALL ( store_progress[store] ), NOT [store] IN existedStores )
    )

A date table is always necessary for the time intelligence functions.

calculation-of-new-records-per-status

 

 

Best Regards,

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

hi , thank you for your answer!

unfortunately, looking at the results, the open status is not working really well.

highlighted where the Yes is expected to be shown, while in Red the wrong attribution. 

 

table.PNG

 

basically, there'd be to create a formula working at a cell level which, for the first time a row made by date&status, has the value "open".

any advice?

best

Hi @Anonymous,

 

You mean we just need to consider the [date] and the [status]. If so, try this one, please.

ifNewOpen =
VAR existedStores =
    CALCULATETABLE (
        VALUES ( store_progress[store] ),
        FILTER (
            ALL ( 'store_progress' ),
            'store_progress'[date] <= EOMONTH ( EARLIER ( [date] ), -1 )
                && store_progress[status] = "open"
        )
    )
RETURN
    IF ( [store] IN existedStores || NOT [status] = "open", "No", "Yes" )

calculation-of-new-records-per-status2

 

Best Regards,

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

it works, that's great! you've made my day 🙂

thanks a lot for your help

Anonymous
Not applicable

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.