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
littlemojopuppy
Community Champion
Community Champion

C# Scripts to Create Measures

Hi!

 

A couple weeks ago I asked for some advice/help on writing a C# script to create measures based on the calculation items in a data model.  I wanted to share what I came up.

 

There are three files in the zip file:

  • A DAX script to create calculation items for different time periods (MTD, QTD, YTD, etc.)
  • A DAX script to create calculation items for comparing time periods (MTD vs. prior MTD, etc.)
  • A C# script to create measures

They can all be executed in Tabular Editor 3 (not sure about TE2...haven't tried it).  Execute the two DAX scripts to create those calculation items.  Then execute the C# script.  It will loop through each of the measures in your model and create a measure based on each of the calculation items.  It'll also add formatting and a basic description.

 

A huge shout out to @parry2k for pointing me in the right direction to get started with this!

1 ACCEPTED SOLUTION
littlemojopuppy
Community Champion
Community Champion

@v-luwang-msft will do!

 

@parry2k: again, thank you for pointing me in the right direction!  🙂

View solution in original post

4 REPLIES 4
littlemojopuppy
Community Champion
Community Champion

@v-luwang-msft will do!

 

@parry2k: again, thank you for pointing me in the right direction!  🙂

v-luwang-msft
Community Support
Community Support

Hi @littlemojopuppy ,

Thank you for sharing.it is helpful. You can reply in your own post after and flag it as an answer. This will help more people, many users, who will only view solved cases.

 

 

Best Regards,
Lucien

@v-luwang-msft @Do you think this would be better served as a blog post?  And not a solution?  I didn't actually ask for help with this...

HI  @littlemojopuppy ,

The forum also often appears to share the post, this does not harm the elegance. Of course, if you're going to blog, you might want to go into more detail.
 
Best Regards
Lucien

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.

Top Solution Authors