Forum Discussion

sdhn's avatar
sdhn
Icon for Responsive Resident rankResponsive Resident
4 years ago
Solved

Rename the files name

Hi All,
 
I have merged multiple files onto one file during transformation & load. I named new file as "Source".
"Source. Name" column has all files name. This column has been created by load process. 
 

We are using following measure to get total counts of each types or files.

 Source = CALCULATE(COUNT(Source[Source.Name]), ALLEXCEPT(Source,Source[Source.Name]))

 

On Dashbaord data is displaying as:

Source.Name
ABC.cvs
TTS.cvs
XYZ.cvs
XYZ.cvs

 

 

I want to displays names differently.

 

e.g: 'ABC.cvs" should be as "Alerts Today"

"TTS.cvs" should be as " Alerts Tomorrow"  etc 

 

Appreciate your help. Thanks 

 
 Note:  I had asked similar question earlier, but did not expalin correctly. 
  • sdhn , Create a new column like

     

    Switch([Source.Name],
    "ABC.cvs" , "Alerts Today",
    "TTS.cvs" ," Alerts Tomorrow"
    //Add others
    [Source.Name]
    )

  • Source = CALCULATE(COUNT(Source[NCol]), ALLEXCEPT(Source,Source[NCol]))
     
    works. Thanks both of you

12 Replies

  • sdhn , Create a new column like

     

    Switch([Source.Name],
    "ABC.cvs" , "Alerts Today",
    "TTS.cvs" ," Alerts Tomorrow"
    //Add others
    [Source.Name]
    )

    • sdhn's avatar
      sdhn
      Icon for Responsive Resident rankResponsive Resident

      Switch([Source.Name],
      "UTRAlerts.cvs" , "Uptime Robot",
      "SCOMAlerts.csv" ," SCOM Alerts",
      "Reactive Tickets Processed.csv","Reactive Tickets Processed",
      "ONMSAlerts.csv","OpenNMS Alert",
      "ATAAlerts.csv", "ATA Alerts"
      //Add others
      [Source.Name]
      )

       

      The syntax for '[Source.Name]' is incorrect. (DAX(Switch([Source.Name],"UTRAlerts.cvs" , "Uptime Robot","SCOMAlerts.csv" ," SCOM Alerts","Reactive Tickets Processed.csv","Reactive Tickets Processed","ONMSAlerts.csv"

  • sdhn's avatar
    sdhn
    Icon for Responsive Resident rankResponsive Resident

    Results:

     

    The following syntax error occurred during parsing: Invalid token, Line 6, Offset 1, "ATAAlerts.csv//Add others[Source.Name]))).

  • sdhn in your last reply, are you asking a question or what? Not clear?

    • sdhn's avatar
      sdhn
      Icon for Responsive Resident rankResponsive Resident

      Getting error 

       

      pl. see my last post above

  • sdhn's avatar
    sdhn
    Icon for Responsive Resident rankResponsive Resident
    NCol = Switch([Source.Name],
    "UTRAlerts.cvs" , "Uptime Robot",
    "SCOMAlerts.csv" ," SCOM Alerts",
    "Reactive Tickets Processed.csv","Reactive Tickets Processed",
    "ONMSAlerts.csv","OpenNMS Alert",
    "ATAAlerts.csv", "ATA Alerts"
    //Add others
    [Source.Name]
    )
     
     
    The syntax for '[Source.Name]' is incorrect. (DAX(Switch([Source.Name],"UTRAlerts.cvs" , "Uptime Robot","SCOMAlerts.csv" ," SCOM Alerts","Reactive Tickets Processed.csv","Reactive Tickets Processed","ONMSAlerts.csv
  • sdhn looks like you are missing a comma:

     

    NCol = Switch([Source.Name],
    "UTRAlerts.cvs" , "Uptime Robot",
    "SCOMAlerts.csv" ," SCOM Alerts",
    "Reactive Tickets Processed.csv","Reactive Tickets Processed",
    "ONMSAlerts.csv","OpenNMS Alert",
    "ATAAlerts.csv", "ATA Alerts",
    [Source.Name]
    )

     

     

    ✨ Follow us on LinkedIn and  to our YouTube channel

     

    Learn about conditional formatting at Microsoft Reactor

    My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    ⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

    • sdhn's avatar
      sdhn
      Icon for Responsive Resident rankResponsive Resident

      Yes.  code works but not results.

       

      Here is the baord before code

       

       I used above codes to rename the file, see results

       

       It is totalling all files counts now.

       

      Here is the code for SOURCE:

      Source = CALCULATE(COUNT(Source[Source.Name]), ALLEXCEPT(Source,Source[Source.Name]))

       

       

      • sdhn's avatar
        sdhn
        Icon for Responsive Resident rankResponsive Resident
        Source = CALCULATE(COUNT(Source[NCol]), ALLEXCEPT(Source,Source[NCol]))
         
        works. Thanks both of you
  • read my LAST REPLY and apply  the fix, no point going back and forth if you don't read the message carefully and apply the change, here it is again

     

    NCol = Switch([Source.Name],
    "UTRAlerts.cvs" , "Uptime Robot",
    "SCOMAlerts.csv" ," SCOM Alerts",
    "Reactive Tickets Processed.csv","Reactive Tickets Processed",
    "ONMSAlerts.csv","OpenNMS Alert",
    "ATAAlerts.csv", "ATA Alerts",
    [Source.Name]
    )
  • sdhn's avatar
    sdhn
    Icon for Responsive Resident rankResponsive Resident

    One more thing. It is counting one extra row for each file. 

     

     

    should be as: