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

Looking for a Dax Measure which can solve my use case

Hi, 

image.png

I am trying to find a way to solve this but stuck , can someone help me out in solving this.

 

I have a table which has 4 columns shown in the picture. I want to count the no.of servers

Conditions has to consider:

  • For each year I need to count the no.of servers that have cloud status as “ public.”
  • Check if the server is used by any other app id in upcoming year and if it is not used then get the count of the servers for that year.

Final o/p expecting:

Ex:      year        server count

           2019         0

      <= 2020         1 (server 6)

      <= 2021          3 (server 6, server 7, server 5)

      <= 2022           4 (server 6, 7, 5, 1)

 

I try to write a measure which was not a good approach but end up as below:

Count =

var PublicCloudServer = SUMMARIZECOLUMNS('servers list'[server Name], FILTER('servers list','servers list'[cloud]= "public" && 'servers list'[date] <= 2022))

var Filter1 = FILTER('servers list','servers list'[cloud]= "public" && 'servers list'[date] <= 2022)

var OtherServerList = SUMMARIZECOLUMNS('servers list'[server Name], EXCEPT('servers list', p))

var UniqueServerList = except( o, o1)

return COUNTROWS(o2)

 

please let me know if there is any diffrent way to solve this.

 

Thanks.

 

1 ACCEPTED SOLUTION

HI @Anonymous ,

You can try to use following measure formula if it works:

decommissioned count = 
VAR currYear =
    MAX ( T1[Year] )
VAR currList =
    CALCULATETABLE (
        VALUES ( T1[Server Name] ),
        FILTER ( ALLSELECTED ( T1 ), [Status] = "public" ),
        VALUES ( T1[Year] )
    )
VAR nextlist =
    CALCULATETABLE (
        VALUES ( T1[Server Name] ),
        FILTER ( ALLSELECTED ( T1 ), [Year] > currYear )
    )
RETURN
    IF (
        currYear <> BLANK ()
            && ISINSCOPE ( T1[Year] ),
        COUNTROWS ( EXCEPT ( currList, nextlist ) )
    )

17.png

On you expect result 2,3 exclude from 2021, I think they are suitable for your conditions.(they haven't appeared in next year)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

>>Check if the server is used by any other app id in upcoming year and if it is not used then get the count of the servers for that year.

I still not so clear for your conditions, can you please explain this more clearly?

For example:

2020 has three public servers, why you say only server 6 suitable for these conditions? If you mean it need to recursive calculate with next records, current power bi not support recursive calculation in dax formula.

Regards,
Xiaoxin Sheng

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

Hi @v-shex-msft ,

Thanks for responding.

my use case is to calculate the server count for the apps which are moving to public cloud ( cloud status "public").

Let me take 2020 year as example:
2020 has 3 public servers (server 6, 2, 4) but server ( 2 & 4 ) are used by other apps (i.e. app id 5, 7, 8, 9 ) in 2021, so I can't consider those servers are decommissioned in 2020. only (server 6) in 2020 was not used by any other apps in the following years so we can count (server 6) as decommissioned in 2020.
Let me know if you understand my use case or else I will try to put it in a different way.

Thanks.

@Anonymous can you share data in excel file using link to onedrive/google drive to work on the solution.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi @parry2k ,

 

appId  serverName  cloud  date

1server 1public2019
1server 1public2019
1server 1public2019
2server 3private2019
3server 6public2020
3server 2public2020
3server 4public2020
4server 3private2020
5server 4private2021
6server 3private2021
7server 4private 
7server 2private 
7server 3private 
7server 4private 
7server 4private 
8server 2public2021
8server 5public2021
8server 5public2021
8server 3public2021
8server 7public2021
9server 3public 
9server 4public 
9server 1public 
9server 2public 
9server 3public 
10server 1public2022
10server 1public2022

 

will this  Table data work  ?

 

Thanks for responding.

HI @Anonymous ,

You can try to use following measure formula if it works:

decommissioned count = 
VAR currYear =
    MAX ( T1[Year] )
VAR currList =
    CALCULATETABLE (
        VALUES ( T1[Server Name] ),
        FILTER ( ALLSELECTED ( T1 ), [Status] = "public" ),
        VALUES ( T1[Year] )
    )
VAR nextlist =
    CALCULATETABLE (
        VALUES ( T1[Server Name] ),
        FILTER ( ALLSELECTED ( T1 ), [Year] > currYear )
    )
RETURN
    IF (
        currYear <> BLANK ()
            && ISINSCOPE ( T1[Year] ),
        COUNTROWS ( EXCEPT ( currList, nextlist ) )
    )

17.png

On you expect result 2,3 exclude from 2021, I think they are suitable for your conditions.(they haven't appeared in next year)

Regards,

Xiaoxin Sheng

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

Hi @v-shex-msft ,

Thanks for your time. very helpful, your Dax Measure works for my use case.

Thanks once again

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.