Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JenniferWallace
Frequent Visitor

Need help with DAX

I want to create table like this.  How will we be able to achieve this using DAX? 

@Dangar332 

NamedollarWeeksdollars/week
Holiday Weeks$5512.34
Non-Holiday Weeks$4.9512.34
4 REPLIES 4
Dangar332
Super User
Super User

Hi, @JenniferWallace 

you want it from manual data entry or based on another table?

 

if it based on manual entry then try @FreemanZ  solution 



if based on another table then try below

 

newtable =
   addcolumn(
       all(tablename[holidayweekcolumn]),
       "dollar" ,calculate(sum(tablename[dollarcolumn])),
       "weeks",weeknum(tablename[datecolumn],2),
       "dollar/week",calculate(sum(tablename[dollar/weekcolumn]))   
   )

 

 

 

 

if it not work then ellaborate your problem

AnalyticPulse
Impactful Individual
Impactful Individual

can you tell us what kind of column and table you have in your data

 

FreemanZ
Super User
Super User

hi @JenniferWallace ,

 

do you mean a calculated table like:

table = 
DATATABLE (
    "Name",STRING,
    "dollar", CURRENCY,
    "Weeks", INTEGER,
    "dollars/week", DOUBLE,
    {
        { "Holiday Weeks", 5, 5, 12.34},
        { "Non-Holiday Weeks", 4.9, 5, 12.34}
    }
)

 

it worked like:

FreemanZ_0-1700464373883.png

 

123abc
Community Champion
Community Champion

To create a table like the one you've described using DAX (Data Analysis Expressions), you can use DAX measures in Power BI or other similar tools. Assuming you have a table in your data model that contains information about different types of weeks (e.g., "Holiday Weeks" and "Non-Holiday Weeks"), you can follow these steps:

  1. Create a New Table: Create a new table in Power BI or your data modeling tool where you can define the structure of your table. You can use the following DAX formula to create a new table:

SummaryTable = VALUES('YourWeeksTable'[WeekType])

 

  1. Replace 'YourWeeksTable' with the actual name of your table containing information about different weeks.

  2. Define DAX Measures: Define the following DAX measures to calculate the desired values:

TotalDollars = SUM('YourWeeksTable'[Dollar])

TotalWeeks = SUM('YourWeeksTable'[Weeks])

DollarsPerWeek = DIVIDE([TotalDollars], [TotalWeeks], 0)

 

To create a table like the one you've described using DAX (Data Analysis Expressions), you can use DAX measures in Power BI or other similar tools. Assuming you have a table in your data model that contains information about different types of weeks (e.g., "Holiday Weeks" and "Non-Holiday Weeks"), you can follow these steps:

  1. Create a New Table: Create a new table in Power BI or your data modeling tool where you can define the structure of your table. You can use the following DAX formula to create a new table:

    daxCopy code
    SummaryTable = VALUES('YourWeeksTable'[WeekType])

    Replace 'YourWeeksTable' with the actual name of your table containing information about different weeks.

  2. Define DAX Measures: Define the following DAX measures to calculate the desired values:

    daxCopy code
    TotalDollars = SUM('YourWeeksTable'[Dollar]) TotalWeeks = SUM('YourWeeksTable'[Weeks]) DollarsPerWeek = DIVIDE([TotalDollars], [TotalWeeks], 0)

    Adjust the column and table names based on your actual data model.

  3. Build the Table: Now, you can use these measures in your new table. Assuming you have a column named WeekType in your SummaryTable, add the following columns:

Name = 'SummaryTable'[WeekType]

Dollar = CALCULATE([TotalDollars], FILTER('YourWeeksTable', 'YourWeeksTable'[WeekType] = 'SummaryTable'[WeekType]))

Weeks = CALCULATE([TotalWeeks], FILTER('YourWeeksTable', 'YourWeeksTable'[WeekType] = 'SummaryTable'[WeekType]))

DollarsPerWeek = CALCULATE([DollarsPerWeek], FILTER('YourWeeksTable', 'YourWeeksTable'[WeekType] = 'SummaryTable'[WeekType]))

 

  1. These columns will retrieve the necessary values for each week type.

Remember to replace 'YourWeeksTable' with the actual name of your table containing the week information.

This way, you will have a table with the desired structure, showing the total dollars, total weeks, and dollars per week for each week type.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.