Here’s a question from Thomas:
Sometimes, while building a model in Power BI Desktop, i would like to create a simple table containing random sales values for a specific date. Any ideas how to go about doing that?
Thanks for the question, please find the detailed step-by-step below:
#1 – Define a dates column
To define a Power BI table containing column dates, proceed as following:
- In Power BI Desktop, open your Table View.
- Hit the New Table button
- Use the following DAX expression to create a table containing 10 rows containing dates for the interval between 1-10 of August 2023.
Sales = CALENDAR (DATE (2023,8,1), DATE(2023,8,10))
- A new table called Sales will be created containing a single date column.
- Note that the column containing the dates values was aumotically renamed to Date.
- Note: You might consider changing your Power BI column Date format to DD/MM/YYY or others.
#2 – Define random values in table rows
To add a random calculated column, proceed as following:
- Stay in your Power BI Table View, and hit the New Column button.
- In your formula bar, type the following DAX expression to create a random sales amount column with values between 10,000 and 50,000 (modify your minimum and maximum values accordingly):
Sales Amount = RANDBETWEEN(10000, 50000)
#3 – Browse your table values
At this point you can browse your newly created random Power BI table values:
- Use the Table to browse your random row values as shown below: