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
Greg_Deckler
Super User
Super User

Do I have to wait for measures in rows or is there another way?

Quick question,

 

I have source data in the following format:

 

StoreNumberTransdateNetCompNetSalesInternetNetSalesTotalOrdersDiscounts
1001/24/2017 0:000.001000.58200.32131100.66
1001/25/2017 0:000.001500.76253.1511810068
1001/26/2017 0:000.002500.43250.54109120.12
1001/27/2017 0:000.007000.83700.25259250.72
1001/28/2017 0:000.007500.62900.33248250.1
1001/29/2017 0:000.005000.23630.79174200.63
1001/30/2017 0:000.002400.40250.76100170.73
1001/31/2017 0:000.002,489.22322.1712290.38
1002/1/2017 0:000.003,907.32393.55134250.12
1002/2/2017 0:000.003,326.48214.02155150.69

 

I need to calculate some measures based on these and addition numbers (more columns not shown here). However, the desired display is in the format:

 

 MondayTuesdayWednesdayThursdayFridaySaturday
Measure 1##################
Measure 2##################
Measure 3##################
Measure 4##################

 

I can create the measures easy enough and obviously get the weekday.

 

Do I have to wait for the planned idea, measures as rows, here:

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/10948962-matrix-measures-or-value...

 

Or does someone have a way that I might be able to accomplish this using some tricky pivoting/unpivoting/grouping of data in the query?

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
17 REPLIES 17
Sean
Community Champion
Community Champion

At the very bottom of this link from (March 8, 2017) there's a NEW survey

https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-matrix-visual/

that was one of the questions

 

But I in the meantime I think there's a hack I've seen from @MattAllington or @ImkeF

Vvelarde
Community Champion
Community Champion

@Greg_Deckler

 

A solution (not even closer the best) would be:

 

1. Create the measures. Smiley Very Happy

2. Create a table with the measures Name:

 

MEasures.png

 

 

3. Create a measure :

 

MeasuretoShow =
IF (
    HASONEVALUE ( 'MeasureTable'[Measures] ),
    SWITCH (
        VALUES ( 'MeasureTable'[Measures] ),
        "Internet Sales"; [MInternetSales],
        "Total Orders"; [MTotalOrders],
        "Discounts"; [MDiscounts],
        "Net Sales"; [MNetSales]
    )
)

4. In a Matrix

 

Matrix.png




Lima - Peru

@Vvelarde to the rescue again! Thanks, I remembered there was a trick to this! Only odd quirk, for some inexplicable reason doing it this way strips out the prescribed formatting through the UI, but the fix is easy enough, just use FORMAT to enforce formatting:

 

M Sales Measures to Show = 
IF(
     HASONEVALUE('Sales Measures'[Sales Measures]),
     SWITCH(
          VALUES('Sales Measures'[Sales Measures]),
          "Sales AUV",FORMAT([M Sales AUV],"Currency"),
          "Transactions",[M Transactions],
          "Average Net Check",FORMAT([M Average Net Check],"Currency"),
          "Online Net Sales %",FORMAT([M Online Net Sales %],"Percent")
	 )
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler - that's a pretty cool trick!

But when I applied it, the measure was then formatted as text and left-aligned  - no good for numbers.

Do you have any idea how to fix this?

 

PBISwitchFormatText.jpg

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sean
Community Champion
Community Champion

@ImkeFThat's odd. Can you share the overall Measure formula?

Thx @Sean for having a look at it. I changed the measure to this:

 

Switch = IF(HASONEVALUE(IndividualAccountsLayout[IsAccounts]),SWITCH(VALUES(IndividualAccountsLayout[IsAccounts]), "No", FORMAT([Act], "Standard"), "Accounts", FORMAT([Plan], "Standard")))

... just to make sure that it cannot be due to different formats assigned.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sean
Community Champion
Community Champion

@ImkeF

I'm sorry I can't duplicate this!

First I changed only 1 of my measures to Format as ''Standard" instead of "Currency" it lost the $ but still had the thousand separator and decimal point and still right justified.

 

Then I changed all 4 Measures to Format as "Standard" again same result % and $ disappear but thousand sepator and decimal remain and still right justified!

 

I replaced the Year I had (whole number) in the Columns with a text category field still same result.

 

@Vvelardeany ideas?

Anonymous
Not applicable

@ImkeF

would you mind to mail me your data and measures as I can't replicate it?

Have an idea but I'm not sure.

Sure - here we go:

https://www.dropbox.com/s/eqcpooduho6uzh4/PBI_SwitchAlignment.pbix?dl=0

Thank you guys!

 

PBI_SwitchAlignment.jpg

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sean
Community Champion
Community Champion

Well @Anonymous that works too! Smiley Very Happy

 

@ImkeFit seems you have 2 options

 

1) multiply *1 the [Neg] and remain with a table visual

OR

2) switch to a Matrix and you don't have to do anything Smiley Happy

(this post was about Measures on Rows in a Matrix so I just assumed you were working in a Matrix)

Anonymous
Not applicable

Thank you @Sean

Hey guys - thx a ton for the solutions - and the deep dive into the subtle but effective differences between tables and matrices in PBI 🙂

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

@ImkeF - it was my pleasure!

Anonymous
Not applicable

Unbenannt.PNG

Just added a "*1" to the negative value.

The alignment seems to be ok, but it is still text...

 

Measure = IF(HASONEVALUE(Table1[Column1]);
	SWITCH(
		VALUES(Table1[Column1]); 
		"1"; FORMAT([Neg]; "Standard")*1;
		"2"; FORMAT([Pos]; "Percent")))

This actually makes sense when you think about it.

 

That's because technically M Sales Measures to Show is a single Measure unto itself.

 

You can't have a single Measure display multiple Formats - at least not yet! Smiley Happy

 

You can Format M Sales Measures to Show in the Modeling tab as 1 type of Format.

 

If all Measures contained within it were the same Format that would work great.

(if all were $ or all % etc...) However that would rarely (if ever) be the case.

 

Hopefully they'll address this soon!

Yes I wrote an article about this here http://exceleratorbi.com.au/measures-on-rows-here-is-how-i-did-it/ 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Sean
Community Champion
Community Champion

@Vvelarde  Yes that was it! Smiley Happy

When all else fails use a Disconnected Table Smiley Very Happy

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.