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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SajjadMousavi
Helper II
Helper II

Creating a new table with measures in rows

Hi

I have a few measures, say M1, M2, M3, which depend on year and month (I already have a date dimension table). Because most of visuals for BSC dashboard and reports, and most of KPI visuals which are suitable for my case, expect measures names to be values in table columns (not single measures), I need to create table like this (from the above measures):

 

YearMonthMeasure nameMeasure value
20201Measure 112
20201Measure 256.6
20201Measure 31.3
............

 

And so on. Now my question is: How can I create a table in the above format from measures which are already mentioned? I know that I MAY be able to do this using Power Query, but there are two problems: First, writing complex calculations for goals, targets and indices in strategy area using Power Query is not as simple as DAX; And second, when I write measures using DAX, I can't use them back in Power Query to create such a table (provided creating such a table in Power Query is possible at all, which I'm not sure about).

 

Thanks in advance.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @SajjadMousavi 
You can start with creating a crossjoin table between Measure Names and the values of Year-Month column of the date table. Something like
Filter Table =
CROSSJOIN ( VALUES ( 'Date'[YearMonth] ), { "Measure 1", "Measure 2", "Measure 3" } )
Then create a relationship between the Year-Month columns in the two tables (many to many). The values column that contains the names of the measures can then be used in the table visual without generating error message about the relationship.

Next is simple. Create one measure wich contains switch statement. Something like
Measure =

VAR SelectedMeasure = SELECTEDVALUE ( 'Filter Table'[Value] )
RETURN
    SWITCH (
        TRUE ( ),
        SelectedMeasure = "Measure 1", [Measure 1],
        SelectedMeasure = "Measure 2", [Measure 2],

        SelectedMeasure = "Measure 3", [Measure 3]
     )

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @SajjadMousavi 
You can start with creating a crossjoin table between Measure Names and the values of Year-Month column of the date table. Something like
Filter Table =
CROSSJOIN ( VALUES ( 'Date'[YearMonth] ), { "Measure 1", "Measure 2", "Measure 3" } )
Then create a relationship between the Year-Month columns in the two tables (many to many). The values column that contains the names of the measures can then be used in the table visual without generating error message about the relationship.

Next is simple. Create one measure wich contains switch statement. Something like
Measure =

VAR SelectedMeasure = SELECTEDVALUE ( 'Filter Table'[Value] )
RETURN
    SWITCH (
        TRUE ( ),
        SelectedMeasure = "Measure 1", [Measure 1],
        SelectedMeasure = "Measure 2", [Measure 2],

        SelectedMeasure = "Measure 3", [Measure 3]
     )

Thanks a lot for your solution. It worked flawlessly! It just needed a small correction in my case (and I don't know why!):

 

VAR SelMeasure = CALCULATE(MAX(MeasureTable[MeasureName]), MeasureTable[MeasureName] = EARLIER(MeasureTable[MeasureName]))
 
The above is because SELECTEDVALUE always returns blank (It's the first time I faced such an issue). The above is a trick I have used before when I needed EARLIER without actually using CALCULATE.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.