Forum Discussion

Aadwark's avatar
Aadwark
New Member
2 years ago
Solved

power bi countrows between range

Hi guys,

 

Im looking for a solution to count how many snapshots do we have which are between 0-5, 5-15 and over 15 days old.

 

I could do it easily in xls like : =COUNTIFS(Actual!I:I,"EMEA",Actual!C:C,">=5",Actual!C:C,"<=15")

 

But i have spent million hours already to figure out how should i do in Power but i still have no idea, i have tried this: CALCULATE(COUNT(Actual[Snapshot Age (Days)]),'Actual'[Snapshot Age (Days)] <5 it was working if i have only 1 variables,

 

but if i wants to have it between the range its not working : 

CALCULATE(COUNT(Actual[Snapshot Age (Days)]),'Actual'[Snapshot Age (Days)] <5,Actual[Snapshot Age (Days)] >15)

 

If you can give me some advice it will be much presiated.

 

Thanks

  • Aadwark , you can simply create a new column

    If [Snapshot Age] is a column and then you can use count of any column

    Switch(true(),

    [Snapshot Age] < 5, "   Days < 5" ,

    [Snapshot Age] < 15, "  Days 5 - 15" ,

     " >15" )

     

    If [Snapshot Age] is measure follow the link I have given in last update

4 Replies

    • Aadwark's avatar
      Aadwark
      New Member

      I will check thanks,

       

      but i also try to make it more clear 🙂

       

      So i have a table with the data like this:

       

      VM nameSnapshot Age
      VM113
      VM2144
      VM324
      VM424
      VM5221
      VM6285
      VM7290
      VM8156

       

      And in xls i could count the number of VMs which has snapshots, and those snaps are between range (old).

      Like we have 13 VM where their snapshot are between 0-5 days old

      than 7 VM where their snapshot are between 5-15 days old

      than 56 VM where their snapshot are between 5-15 days old

       

      EMEA
      DaysNumber
      513
      5-157
      1556

       

      I also could make it done in Power when i have used a single xls file, but all of my calculation was inside the xls so the power only visualized, but because i have multiple location i would automate it and grab all xls from a folder, therefore i cannot have any calculation inside of the xls files so it has to be done in Power.

       

       

      i hope its more clear now 😛

      Thanks

      • amitchandak's avatar
        amitchandak
        Super User

        Aadwark , you can simply create a new column

        If [Snapshot Age] is a column and then you can use count of any column

        Switch(true(),

        [Snapshot Age] < 5, "   Days < 5" ,

        [Snapshot Age] < 15, "  Days 5 - 15" ,

         " >15" )

         

        If [Snapshot Age] is measure follow the link I have given in last update