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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

how to present the number above and below a claim without rows to base on

I have a dataset that represents training hours for each person for each month. For each month, a person must have 60 minutes of training - this means that if you have exercised for 120 minutes in January you are still above the requirement in February, if you do not have any hours this month. As a result, I do not have one row for each person in my dataset for each month.

I have used the totalytd method to present the total training for each month an presents the data in a matrix. But I want to present the number of people who are above and below the requirement for June (360 minutes) in a pie chart or similar. How can I do this when I do not have rows to count on?


TotalMinYTD = TOTALYTD(SUM(Training[TotalMin);Date[Date])

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur , so here are my tables:
Matrix.JPG

trainings.JPG     DateTable.JPG

And here are the measures I've used in the matrix:

TotalYTD = TOTALYTD(SUM(Trainings[TrainingHour]);'Date'[Date])

CheckColour = [TotalYTD]-60*(SELECTEDVALUE('Date'[MonthNr])-1)

FillColour = IF([CheckColour] >=60;2;1)



What i want now is to create a way for the user to sort the matrix into people that are over the requirement of may (360 min) and the people that are under. I also want to create a visual that shows the count of people who are over or under the requirement.

Hi,

I cannot understand your question.  Someone else who does will help you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
smpa01
Super User
Super User

@Anonymous  I solved this using M and still looking for a way to solve this using DAX

 

Started with this

NameDateHours
Sam11/1/201860
Sam12/31/2018120
Sam2/1/201955
Sam3/1/2019185
Sam6/1/201990
Peter1/1/200656
Peter2/1/2006364

Achieved this

NameDateHoursMonth_ExpansionQualifying and NonQualifying Hours
Sam11/1/20186011/30/201860
Sam12/31/201812012/31/201860
Sam12/31/20181201/31/201960
Sam2/1/2019552/28/201955
Sam3/1/20191853/31/201960
Sam3/1/20191854/30/201960
Sam3/1/20191855/31/201960
Sam3/1/20191856/30/20195
Sam6/1/2019906/30/201960
Sam6/1/2019907/31/201930
Peter1/1/2006561/31/200656
Peter2/1/20063642/28/200660
Peter2/1/20063643/31/200660
Peter2/1/20063644/30/200660
Peter2/1/20063645/31/200660
Peter2/1/20063646/30/200660
Peter2/1/20063647/31/200660
Peter2/1/20063648/31/20064

through this

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7MVdJRMjTUN9Q3MjC0ALLNDJRideASRvrGcBlDI2QpI4gWSyDT1BRJ3BghbmiBLGGGkLCEGBSQWpJaBFIHljEwAxllhiJjhJAxNjNRio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Date = _t, Hours = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Hours", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, {{"ad", each _, type table [Name=text, Date=date, Hours=number]}}),
#"Added Custom8" = Table.AddColumn(#"Grouped Rows", "Custom", each let
Source=[ad],
Sort=Table.Sort(Source,{{"Date", Order.Ascending}})

in
Sort),
#"Removed Other Columns1" = Table.SelectColumns(#"Added Custom8",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns1", "Custom", {"Name", "Date", "Hours"}, {"Name", "Date", "Hours"}),
#"Added Custom" = Table.AddColumn(#"Expanded Custom", "Custom", each [Hours]/60),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if [Custom]=1 then "1" else if [Custom]<1 then "Less than 1" else "Greater than 1"),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each if Number.Mod([Custom],1)=0 then "Integer" else "Decimal"),
#"Inserted Integer-Division" = Table.AddColumn(#"Added Custom2", "Integer-Division", each Number.IntegerDivide([Custom], 1), Int64.Type),
#"Added Custom3" = Table.AddColumn(#"Inserted Integer-Division", "Custom.3", each if [Custom.2]="Integer" and [Custom.1]="1" then 1
else
if [Custom.2]="Decimal" and [Custom.1]="Less than 1"
then 1
else if [Custom.2]="Integer" and [Custom.1]="Greater than 1" then [Custom]
else
if [Custom.2]="Decimal" and [Custom.1]="Greater than 1" then [#"Integer-Division"]+1
else 0),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom3",{"Name", "Date", "Hours", "Custom", "Custom.3"}),
#"Inserted Year" = Table.AddColumn(#"Removed Other Columns", "Year", each Date.Year([Date]), Int64.Type),
#"Inserted Month" = Table.AddColumn(#"Inserted Year", "Month", each Date.Month([Date]), Int64.Type),
#"Added Custom4" = Table.AddColumn(#"Inserted Month", "End", each if [Custom.3]=1 then #date([Year],[Month],1) else Date.AddMonths(#date([Year],[Month],1),[Custom.3])),
#"Added Custom5" = Table.AddColumn(#"Added Custom4", "Start", each #date([Year],[Month],1)),
#"Inserted Date Subtraction" = Table.AddColumn(#"Added Custom5", "Subtraction", each Duration.Days([End] - [Start]), Int64.Type),
#"Added Custom6" = Table.AddColumn(#"Inserted Date Subtraction", "Custom.1", each if [Subtraction]<>0 then List.Dates([Start],[Subtraction],#duration(1,0,0,0)) else List.Dates([Start],1,#duration(1,0,0,0))),
#"Added Custom7" = Table.AddColumn(#"Added Custom6", "Custom.2", each let
Source=[Custom.1],
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Calculated End of Month" = Table.TransformColumns(#"Converted to Table",{{"Column1", Date.EndOfMonth, type date}}),
#"Removed Duplicates" = Table.Distinct(#"Calculated End of Month"),
Column1 = #"Removed Duplicates"[Column1]
in
Column1),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom7",{"Custom.1"}),
#"Expanded Custom.2" = Table.ExpandListColumn(#"Removed Columns", "Custom.2"),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Custom.2",{{"Custom.2", "Month_Expansion"}}),
#"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1),
Custom7 = #"Inserted Integer-Division",
Custom8 = Table.AddColumn(Custom7, "Custom.3", each if [Custom.2]="Integer" and [Custom.1]="1" then 1
else
if [Custom.2]="Decimal" and [Custom.1]="Less than 1"
then 0
else if [Custom.2]="Integer" and [Custom.1]="Greater than 1" then [Custom]
else
if [Custom.2]="Decimal" and [Custom.1]="Greater than 1" then [#"Integer-Division"]+1
else 0),
Custom1 = Table.SelectColumns(Custom8,{"Name", "Date", "Hours", "Custom", "Custom.3"}),
Custom3 = Table.AddColumn(Custom1, "Custom.1", each Number.Mod([Hours],60)),
Custom4 = Table.AddColumn(Custom3, "Custom.2", each if [Custom.3]=1 then {60} else if [Custom.3]=0 then {[Hours]} else if [Custom.3]>1 and Number.Mod([Hours],60)=0 then List.Repeat({60},[Custom.3]) else List.Repeat({60},[Custom.3]-1)),
Custom5 = Table.AddColumn(Custom4, "Remainder Hours", each if [Custom.3]=1 then "" else if [Custom.3]=0 then "" else if [Custom.3]>1 and Number.Mod([Hours],60)=0 then "" else {[Hours]-(([Custom.3]-1)*60)}),
Custom6 = Table.AddColumn(Custom5, "Custom.4", each if [Remainder Hours]="" then [Custom.2] else List.Combine({[Custom.2],[Remainder Hours]})),
#"Removed Columns1" = Table.RemoveColumns(Custom6,{"Custom.2", "Remainder Hours"}),
#"Expanded Custom.4" = Table.ExpandListColumn(#"Removed Columns1", "Custom.4"),
#"Added Index1" = Table.AddIndexColumn(#"Expanded Custom.4", "Index", 1, 1),
#"Merged Queries" = Table.NestedJoin(#"Added Index", {"Index"}, #"Added Index1", {"Index"}, "Added Index1", JoinKind.LeftOuter),
#"Expanded Added Index1" = Table.ExpandTableColumn(#"Merged Queries", "Added Index1", {"Custom.4"}, {"Qualifying and NonQualifying Hours"}),
#"Removed Other Columns2" = Table.SelectColumns(#"Expanded Added Index1",{"Name", "Date", "Hours", "Month_Expansion", "Qualifying and NonQualifying Hours"})
in
#"Removed Other Columns2"

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Greg_Deckler
Super User
Super User

Just divide by MONTH(Date[Date]). For June, this will be 6.


Follow on LinkedIn
@ 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...
Anonymous
Not applicable

Thank you for quick respons @Greg_Deckler. But dividing the measure by six, won't give me a total number of people over and under the requirements? 

What I want is to be able to present the total number of people above and below the requirement in a pie chart. So that one can choose to sort the matrix and see only people above or below the requirement.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.